Exemplo n.º 1
0
        public async Task <IActionResult> EditEpic(string epicId, EpicToReturnDto epicToReturnDto)
        {
            int eId        = Convert.ToInt32(epicId);
            var epicFromDB = await _context.Epics.FindAsync(eId);

            if (epicFromDB == null)
            {
                return(NotFound("An Error Occured"));
            }
            epicFromDB.EpicName        = epicToReturnDto.epicName;
            epicFromDB.EpicDescription = epicToReturnDto.epicDescription;
            await _context.SaveChangesAsync();

            return(Ok(epicToReturnDto));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> CreateEpic(string projectId, EpicToReturnDto epic)
        {
            int pId     = Convert.ToInt32(projectId);
            var project = await _context.Projects.FindAsync(pId);

            if (project == null)
            {
                return(NotFound("Project Not Found"));
            }

            var epicToSave = _mapper.Map <Epic>(epic);

            epicToSave.ProjectId = pId;
            await _context.Epics.AddAsync(epicToSave);

            await _context.SaveChangesAsync();

            return(Ok());
        }