public Entities.Size Map(Domain.Models.Size model, Entities.AnimalsDbContext context) { Entities.SIZE_TYPE sizeType; switch (model) { case Domain.Models.SmallSize: sizeType = Entities.SIZE_TYPE.Small; break; case Domain.Models.MediumSize: sizeType = Entities.SIZE_TYPE.Medium; break; case Domain.Models.LargeSize: sizeType = Entities.SIZE_TYPE.Large; break; default: throw new ArgumentException("SizeMapper encountered an unknown type when mapping from Domain Model to DB Model"); } var dbSize = context.Sizes.FirstOrDefault(s => s.SizeType == sizeType); if (dbSize is not null) { return(dbSize); } Entities.Size size = new Entities.Size(); size.SizeType = sizeType; size.Price = model.Price; return(size); }
public Entities.Size Map(Domain.Models.Size model) { Entities.SIZE_TYPE sizeType; switch (model) { case Domain.Models.SmallSize: sizeType = Entities.SIZE_TYPE.Small; break; case Domain.Models.MediumSize: sizeType = Entities.SIZE_TYPE.Medium; break; case Domain.Models.LargeSize: sizeType = Entities.SIZE_TYPE.Large; break; default: throw new ArgumentException("SizeMapper encountered an unknown type when mapping from Domain Model to DB Model"); } Entities.Size size = new Entities.Size(); size.SizeType = sizeType; size.Price = model.Price; return(size); }
public Entities.Size Map(Domain.Models.Size Size) { return(new Entities.Size { ID = Size.ID, Name = Size.Name, Price = Size.Price }); }