Esempio n. 1
0
        public ActionResult EditingInline_Create([DataSourceRequest] DataSourceRequest request, Transporter transporter)
        {
            if (transporter != null && ModelState.IsValid)
            {
                transportService.AddTransporter(transporter);
            }

            return(Json(new[] { transporter }.ToDataSourceResult(request, ModelState)));
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        public async Task <ActionResult> AddTransporter([FromBody] Transporter transporter)
        {
            var addTransporterResult = await transporterService.AddTransporter(transporter);

            if (!addTransporterResult.IsSuccessful)
            {
                return(BadRequest(addTransporterResult));
            }

            return(Ok(addTransporterResult));
        }