public ActionResult AddGroup(GroupViewModel groupViewModel) { try { if (ModelState.IsValid) { GroupDTO groupDto = _mapper.Map <GroupViewModel, GroupDTO>(groupViewModel); var groupId = _timeTableService.AddGroup(groupDto); return(Json(new { success = true, id = groupId })); } } catch (ValidationException ex) { ViewBag.Error = ex.Message; return(Json(new { success = false, errorMessage = ex.Message })); } return(PartialView("_AddGroupFormPartial", groupViewModel)); }