Exemple #1
0
 public void CombineToDbEntity(ref Application.User user)
 {
     user.NickName    = NickName;
     user.Country     = Country;
     user.Province    = Province;
     user.Address     = Address;
     user.City        = City;
     user.Degree      = Degree;
     user.District    = District;
     user.Phone       = Phone;
     user.Description = Description;
 }
Exemple #2
0
        public static ResponseDto FromDbEntity(Application.User entity)
        {
            if (entity is null || string.IsNullOrEmpty(entity.UserId))
            {
                throw new ArgumentNullException(nameof(Application.User));
            }

            var responseDto = new ResponseDto();

            responseDto.Address    = entity.Address;
            responseDto.City       = entity.City;
            responseDto.Country    = entity.Country;
            responseDto.Degree     = entity.Degree;
            responseDto.District   = entity.District;
            responseDto.LastSignAt = entity.LastSignAt;
            responseDto.NickName   = entity.NickName;
            responseDto.Province   = entity.Province;
            responseDto.UserId     = entity.UserId;
            responseDto.Books      = new List <BookDto>();

            if (entity.Books.Any())
            {
                var books = entity.Books.Select(item => new BookDto()
                {
                    BookId      = item.BookId,
                    BookName    = item.BookName,
                    Category    = new Category.CategoryDto(item.Category.CategoryId, item.Category.CategoryName),
                    Level       = item.Level,
                    PublishedAt = item.PublishedAt,
                    Tags        = item.Tags.Contains(",") ? item.Tags.Split(",").ToList() : new List <string>()
                    {
                        item.Tags
                    }
                }).ToList();

                responseDto.Books = books;
            }

            return(responseDto);
        }