public ActionResult EditingInline_Create([DataSourceRequest] DataSourceRequest request, Transporter transporter) { if (transporter != null && ModelState.IsValid) { transportService.AddTransporter(transporter); } return(Json(new[] { transporter }.ToDataSourceResult(request, ModelState))); }
public virtual ActionResult Create(Transporter transporter) { if (_transporterService.IsNameValid(transporter.TransporterID, transporter.Name)) { ModelState.AddModelError("Name", "Transporter Name should be Unique"); } if (ModelState.IsValid) { _transporterService.AddTransporter(transporter); return(Json(new { sucess = true })); } return(PartialView(transporter)); //if (!repository.Transporter.IsNameValid(transporter.TransporterID, transporter.Name)) //{ // ModelState.AddModelError("Name", "Transporter Name should be Unique"); //} //if (ModelState.IsValid) //{ // repository.Transporter.Add(transporter); // return Json(new { success = true }); //} //return PartialView(transporter); }
public async Task <ActionResult> AddTransporter([FromBody] Transporter transporter) { var addTransporterResult = await transporterService.AddTransporter(transporter); if (!addTransporterResult.IsSuccessful) { return(BadRequest(addTransporterResult)); } return(Ok(addTransporterResult)); }