コード例 #1
0
        public ActionResult AddTimeTable(TimeTableViewModel timeTableViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    GroupDTO     groupDto     = _timeTableService.GetGroupDTOById(new Guid(timeTableViewModel.GroupId));
                    TimeTableDTO timeTableDto = _mapper.Map <TimeTableViewModel, TimeTableDTO>(timeTableViewModel);
                    var          timeTableId  = _timeTableService.AddTimeTable(timeTableDto);
                    return(Json(new { success = true, id = timeTableId, GroupName = groupDto.Name }));
                }
            }
            catch (ValidationException ex)
            {
                ViewBag.Error = ex.Message;
                return(Json(new { success = false, errorMessage = ex.Message }));
            }

            return(PartialView("_AddTimeTableFormPartial", timeTableViewModel));
        }