public ActionResult Edit(MarketCreateDTO req) { Response res = new Response(); if (ModelState.IsValid) { try { if (req.Id > 0) { res.Data = _marketRepository.Update(req); } else { res.Data = _marketRepository.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)); }