public async Task <JsonResult> AddPositionJSON(PositionViewModel position) { try { var positionDto = new PositionDTO { Id = position.Id, Name = position.Name, MaxQuantity = position.MaxQuantity }; if (position.Id > 0) { await positionService.EditPositionTask(positionDto); } else { await positionService.AddPositionTask(positionDto); } return(Json(new { success = true, data = position }, JsonRequestBehavior.AllowGet)); } catch (ValidationException ex) { ModelState.AddModelError(ex.Property, ex.Message); return(Json(new { success = false, errorstring = ex.Message }, JsonRequestBehavior.AllowGet)); } }