public IHttpActionResult EditTask(NewJobBindingModel job)
 {
     _jobService.EditJob(job);
     if(ModelState.IsValid && _jobService.CheckExists(job.Name)) {
         return Ok();
     } else {
         return BadRequest();
     }
 }
Exemple #2
0
        public void EditJob(NewJobBindingModel dto)
        {
            var job = _jobRepo.Get(dto.Id).FirstOrDefault();

            job.Name = dto.Name;
            job.Estimate = dto.Estimate;
            job.Deadline = dto.Deadline;
            job.State = (dto.State == null) ? (Project.Status)Enum.Parse(typeof(Project.Status), "ToDo") : (Project.Status)Enum.Parse(typeof(Project.Status), dto.State);
            job.ContractorId = dto.ContractorId;
            job.Description = dto.Description;

            _jobRepo.SaveChanges();
        }
Exemple #3
0
        //Add a new job
        public void AddJob(NewJobBindingModel dto)
        {
            var job = new Job() {
                Name = dto.Name,
                Description = dto.Description,
                Estimate = dto.Estimate,
                ContractorId = dto.ContractorId,
                State = (dto.State == null) ? (Project.Status)Enum.Parse(typeof(Project.Status), "ToDo") : (Project.Status)Enum.Parse(typeof(Project.Status), dto.State),
                Deadline = dto.Deadline,
                ProjectId = dto.ProjectId
            };

            _jobRepo.Add(job);
            _jobRepo.SaveChanges();
        }