Summary

Class:ProjectX.PublicApi.Actions.Users.UserModelExtensions
Assembly:ProjectX.PublicApi
File(s):C:\private\projects\projectx\backend\src\ProjectX.PublicApi\Actions\Users\UserModelExtensions.cs
Covered lines:30
Uncovered lines:0
Coverable lines:30
Total lines:71
Line coverage:100%

History

Metrics

MethodCyclomatic complexity  NPath complexity  Sequence coverage  Branch coverage  
ToModel(...)10100100
ToDetailsModel(...)10100100
UpdateFromModel(...)10100100

File(s)

C:\private\projects\projectx\backend\src\ProjectX.PublicApi\Actions\Users\UserModelExtensions.cs

#LineLine coverage
 1using System;
 2using ProjectX.Entities;
 3
 4namespace ProjectX.PublicApi.Actions.Users
 5{
 6    public static class UserModelExtensions
 7    {
 8        /// <summary>
 9        /// Creates a DTO instance
 10        /// </summary>
 11        /// <param name="entity"></param>
 12        /// <returns></returns>
 13        public static UserModel ToModel(
 14            this User entity)
 15        {
 316            return new UserModel
 317            {
 318                Id = entity.Id,
 319                IsNew = entity.IsNew(),
 320                Name = entity.Name,
 321                Age = entity.Age,
 322                Gender = entity.Gender,
 323                Info = entity.Info,
 324                Locale = entity.Locale,
 325                Perimeter = entity.Perimeter,
 326                AgeFrom = entity.AgeFrom,
 327                AgeTo = entity.AgeTo
 328            };
 29        }
 30
 31        /// <summary>
 32        /// Creates a DTO instance
 33        /// </summary>
 34        /// <param name="entity"></param>
 35        /// <returns></returns>
 36        public static UserDetailsModel ToDetailsModel(
 37            this User entity)
 38        {
 139            return new UserDetailsModel
 140            {
 141                Id = entity.Id,
 142                Name = entity.Name,
 143                Age = entity.Age,
 144                Gender = entity.Gender,
 145                Info = entity.Info
 146            };
 47        }
 48
 49        /// <summary>
 50        /// Updates a entity from DTO
 51        /// </summary>
 52        /// <param name="entity"></param>
 53        /// <param name="model"></param>
 54        /// <returns></returns>
 55        public static User UpdateFromModel(
 56            this User entity,
 57            UserModel model)
 58        {
 159            entity.Name = model.Name;
 160            entity.Age = model.Age;
 161            entity.Gender = model.Gender;
 162            entity.Info = model.Info;
 163            entity.Locale = model.Locale;
 164            entity.Perimeter = model.Perimeter;
 165            entity.AgeFrom = model.AgeFrom;
 166            entity.AgeTo = model.AgeTo;
 67
 168            return entity;
 69        }
 70    }
 71}