public ActionResult Update(TicketCategory ticketCategory) { ApiResult <TicketCategory> apiResult; if (ModelState.IsValid) { if (ticketCategory.Id > 0) { apiResult = TryExecute(() => { _ticketCategoryRepository.Update(ticketCategory); _unitOfWork.Commit(); return(ticketCategory); }, "Ticket Category updated sucessfully"); } else { apiResult = TryExecute(() => { _ticketCategoryRepository.Create(ticketCategory); _unitOfWork.Commit(); return(ticketCategory); }, "Ticket Category created sucessfully"); } } else { apiResult = ApiResultFromModelErrors <TicketCategory>(); } return(Json(apiResult, JsonRequestBehavior.AllowGet)); }