public ActionResult Edit(BoxCreateDTO req) { Response res = new Response(); if (ModelState.IsValid) { try { if (req.Id > 0) { res.Data = _boxRepository.Update(req); } else { res.Data = _boxRepository.Create(req); } } catch (Exception ex) { res.Message = ex.Message; } } else { res.Data = false; res.Message = string.Join(",", ModelState .SelectMany(ms => ms.Value.Errors) .Select(e => e.ErrorMessage)); } return(Json(res, JsonRequestBehavior.AllowGet)); }