コード例 #1
0
ファイル: ToModel.cs プロジェクト: iFevral/education
        public static PrintingEditionModelItem MapToModel(this DataAccess.Entities.PrintingEdition entity)
        {
            var model = new PrintingEditionModelItem();

            model.Id          = entity.Id;
            model.Title       = entity.Title;
            model.Description = entity.Description;
            model.Price       = entity.Price;
            model.Currency    = entity.Currency;
            model.Type        = entity.Type;
            model.Image       = string.IsNullOrWhiteSpace(entity.Image)
                ? Constants.Constants.Images.DefaultPrintingEditionTitle
                : entity.Image;

            foreach (var item in entity.AuthorInPrintingEditions)
            {
                if (item == null)
                {
                    continue;
                }
                var author = new AuthorModelItem();
                author.Id   = item.AuthorId;
                author.Name = item.Author.Name;

                model.Authors.Add(author);
            }

            return(model);
        }
コード例 #2
0
ファイル: ToEntity.cs プロジェクト: iFevral/education
        public static DataAccess.Entities.PrintingEdition MapToEntity(this PrintingEditionModelItem model, DataAccess.Entities.PrintingEdition entity)
        {
            entity.Title       = model.Title;
            entity.Description = model.Description;
            entity.Price       = model.Price;
            entity.Currency    = model.Currency;
            entity.Type        = model.Type;
            entity.Image       = model.Image;

            return(entity);
        }