public IActionResult Create(ProjectModel projectModel) { try { if (ModelState.IsValid) { ProjectBLO projectBLO = new ProjectBLO(); projectBLO = converter.Convert(projectModel); projectService.Insert(projectBLO); return(RedirectToAction("Index")); } else { return(RedirectToAction("Create")); } } catch (Exception ex) { logger.LogError("Не удалось внести информацию о проекте"); ErrorViewModel error = new ErrorViewModel() { source = ex.Source, message = ex.Message, stackTrace = ex.StackTrace }; return(RedirectToAction("Error", "Home", error)); } }
public IActionResult Task(ProjectModel projectModel) { try { if (ModelState.IsValid) { ProjectBLO projectBLO = new ProjectBLO(); projectBLO = converter.Convert(projectModel); ProjectModel project = new ProjectModel(); if (projectModel.ProjectId == 0) { int id = projectService.Insert(projectBLO); project = converter.Convert(projectService.GetById(id)); } else { projectService.Update(projectBLO); project = projectModel; } return(RedirectToAction("CreateByProject", "Task", project)); } else { return(RedirectToAction("Create")); } } catch (Exception ex) { logger.LogError("Не удалось внести информацию о проекте"); ErrorViewModel error = new ErrorViewModel() { source = ex.Source, message = ex.Message, stackTrace = ex.StackTrace }; return(RedirectToAction("Error", "Home", error)); } }