public IActionResult DeleteCustomer(CustomerVm model) { var entityModel = CustomerVm.MapToEntityModel(model); _settingsBlProvider.DeleteCustomer(entityModel); return(RedirectToAction("CustomerManagement", "Settings")); }
public IActionResult NewOrEditCustomer(CustomerVm model) { if (ModelState.IsValid) { var entityModel = CustomerVm.MapToEntityModel(model); _settingsBlProvider.AddOrUpdateCustomer(entityModel, model.UserIds); } return(RedirectToAction("CustomerManagement", "Settings")); }
public static Entities.Entities.Invoice MapToEntityModel(InvoiceVm source) { var config = new MapperConfiguration(cfg => cfg.CreateMap <InvoiceVm, Entities.Entities.Invoice>() .ForMember(x => x.Customer, y => y.MapFrom(z => CustomerVm.MapToEntityModel(z.Customer))) ); var mapper = config.CreateMapper(); var destination = mapper.Map <Entities.Entities.Invoice>(source); return(destination); }
public static Entities.Entities.Order MapToEntityModel(OrderVm source) { var config = new MapperConfiguration(cfg => cfg.CreateMap <OrderVm, Entities.Entities.Order>() .ForMember(x => x.OrderItems, y => y.MapFrom(z => z.OrderDetails.Select(OrderDetailVm.MapToEntityModel))) .ForMember(x => x.Customer, y => y.MapFrom(z => CustomerVm.MapToEntityModel(z.Customer))) ); var mapper = config.CreateMapper(); var destination = mapper.Map <Entities.Entities.Order>(source); return(destination); }