public async Task <ActionResult> New(Carrier newCarrier) { if (ModelState.IsValid) { int customerId = await _carrierService.AddCarrier(newCarrier); return(RedirectToAction("Carriers")); } var breadCrumbs = new BreadcrumbModel("New Customer", new List <BreadcrumbLink>()); breadCrumbs.Links.Add(new BreadcrumbLink(Url.Action("Carriers", "Settings", null, this.Request.Url.Scheme), "Carriers")); ViewBag.BreadCrumbs = breadCrumbs; return(this.View()); }
public ActionResult Create(CarrierViewModel carrier) { var userName = User.Identity.Name; var userId = _userService.FindUser(userName).Id; if (ModelState.IsValid) { var registeredCarrier = _carrierService.FindCarrier(Mapper.Map <CarrierDTO>(carrier).Name); if (registeredCarrier != null) { ModelState.AddModelError("", "Такой курьер уже существует."); } else { carrier.UserId = userId; _carrierService.AddCarrier(Mapper.Map <CarrierDTO>(carrier)); } } return(RedirectToAction("Index")); }
public ActionResult AddCarrier(CarrierModel carrier) { try { if (ModelState.IsValid) { var result = _carrierService.AddCarrier(carrier); if (result) { ViewBag.Message = "Partner details added successfully"; } } return(View()); } catch (Exception ex) { return(View()); } }
private bool AddCarrier(CarrierModel carrierModel) { var editWindow = new EditCarrierWindow(); var ctx = (EditCarrierViewModel)editWindow.DataContext; ctx.Carrier = carrierModel; if (editWindow.ShowDialog() != true) { return(false); } var errs = GetModelErrors(ctx.Carrier); if (errs != string.Empty) { ShowError(errs, "Error! Saving cancelled. "); return(false); } _carrierService.AddCarrier(carrierModel); return(true); }