Esempio n. 1
0
        public int AddProject(NewProjectVm projectVm)
        {
            var project = _mapper.Map <Project>(projectVm);
            var id      = _destRepo.AddProject(project);

            return(id);
        }
Esempio n. 2
0
 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"));
 }
Esempio n. 5
0
        public IActionResult EditProject([FromBody] NewProjectVm projVm)
        {
            var isExist = _destService.CheckIfProjectExist(projVm.Id);

            if (!ModelState.IsValid || !isExist)
            {
                return(Conflict(ModelState));
            }
            _destService.UpdateProject(projVm);
            return(Ok());
        }
Esempio n. 6
0
        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));
        }
Esempio n. 7
0
        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));
        }
Esempio n. 8
0
        public void UpdateProject(NewProjectVm projectVm)
        {
            var project = _mapper.Map <Project>(projectVm);

            _destRepo.UpdateProject(project);
        }