public int AddProject(NewProjectVm projectVm) { var project = _mapper.Map <Project>(projectVm); var id = _destRepo.AddProject(project); return(id); }
public IActionResult AddProject([FromBody] NewProjectVm projVm) { if (!ModelState.IsValid || projVm.Id != 0) { return(Conflict(ModelState)); } _destService.AddProject(projVm); return(Ok()); }
public IActionResult AddProject() { var model = new NewProjectVm() { Destinations = _destService.GetDestinations().ToList() }; return(PartialView(model)); }
public IActionResult EditProject(NewProjectVm projVm) { if (!ModelState.IsValid) { projVm.Destinations = _destService.GetDestinations().ToList(); return(PartialView(projVm)); } _destService.UpdateProject(projVm); return(RedirectToAction("Projects")); }
public IActionResult EditProject([FromBody] NewProjectVm projVm) { var isExist = _destService.CheckIfProjectExist(projVm.Id); if (!ModelState.IsValid || !isExist) { return(Conflict(ModelState)); } _destService.UpdateProject(projVm); return(Ok()); }
public IActionResult New() { // Summary // // Returns New Project form, distinct from the Edit Project form var vm = new NewProjectVm { Project = new Project() }; return(View("NewProjectForm", vm)); }
public async Task <IActionResult> Submit(NewProjectVm vm) { // Summary // // Post submitted Project to the internal API, redirect to either index or // back to form based on success if (!ModelState.IsValid) { return(View("New", vm)); } var result = await _projectsApi.PostProjectAsync(vm.Project); return(result.IsSuccessStatusCode ? RedirectToAction("Index") : RedirectToAction("New", vm)); }
public void UpdateProject(NewProjectVm projectVm) { var project = _mapper.Map <Project>(projectVm); _destRepo.UpdateProject(project); }