示例#1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,TaskName,TaskStart,EstimateHours,TaskDescription,Completed,ProjectId,ResponsibleId")] JobTaskDTO jobTaskDTO)
        {
            if (id != jobTaskDTO.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await _jobTaskManager.UpdateAsync(jobTaskDTO);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!(_jobTaskManager.ExistAsync(jobTaskDTO.Id)))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProjectId"]     = new SelectList(_context.Projects, "Id", "Name", jobTaskDTO.ProjectId);
            ViewData["ResponsibleId"] = new SelectList(_context.Users, "Id", "UserName", jobTaskDTO.ResponsibleId);

            return(View(jobTaskDTO));
        }
        public async Task <JobTaskDTO> UpdateAsync(JobTaskDTO jobTaskDTO)
        {
            var jobTask = _mapper.Map <JobTask>(jobTaskDTO);

            _context.Update(jobTask);
            await _context.SaveChangesAsync();

            return(_mapper.Map <JobTaskDTO>(jobTask));
        }
示例#3
0
        public async Task <IActionResult> Create([Bind("Id,TaskName,TaskStart,EstimateHours,TaskDescription,Completed,ProjectId,ResponsibleId")] JobTaskDTO jobTaskDTO)
        {
            if (ModelState.IsValid)
            {
                await _jobTaskManager.CreateAsync(jobTaskDTO);

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProjectId"]     = new SelectList(_context.Projects, "Id", "Name", jobTaskDTO.ProjectId);
            ViewData["ResponsibleId"] = new SelectList(_context.Users, "Id", "UserName", jobTaskDTO.ResponsibleId);

            return(View(jobTaskDTO));
        }