public IActionResult DeliveryDetail(long deliveryId) { var deliveryVm = DeliveryVm.MapToViewModel(_deliveryBlProvider.GetSingle(deliveryId)); return(PartialView("_OrderDetail", deliveryVm)); }
public IActionResult NewDelivery() { ViewBag.Customers = _settingsBlProvider.GetCustomers() .Select(t => new SelectModel() { label = t.Name, value = t.Id }).ToList(); var deliveryVm = new DeliveryVm(); return(PartialView("_NewDelivery", deliveryVm)); }
public IActionResult NewDelivery(DeliveryVm model) { var list = new List <string>(); string response; if (ModelState.IsValid) { try { if (model.OrderDetails != null) { if (model.OrderDetails.Any(t => string.IsNullOrEmpty(t.ProductName))) { list.Add(ErrorMessages.valProductNameRequired); return(Json(list)); } } var entityModel = DeliveryVm.MapToEntityModel(model); _deliveryBlProvider.AddItem(entityModel); response = "ok"; } catch (Exception) { response = "failure"; } } else { foreach (var modelStateValue in ModelState.Values) { if (modelStateValue.ValidationState != ModelValidationState.Invalid) { continue; } if (!list.Any(t => t.Equals(modelStateValue.AttemptedValue))) { list.Add(modelStateValue.AttemptedValue); } } return(Json(list)); } list.Add(response); return(Json(list)); }
public static AttachmentVm MapToViewModel(Entities.Entities.Attachment source) { var config = new MapperConfiguration(cfg => cfg.CreateMap <Entities.Entities.Attachment, AttachmentVm>() .ForMember(x => x.Delivery, y => y.MapFrom(z => DeliveryVm.MapToViewModel(z.Delivery))) ); var mapper = config.CreateMapper(); var destination = mapper.Map <AttachmentVm>(source); return(destination); }