public async Task <IActionResult> PutUsers(int id, User users) { if (id != users.Id) { return(BadRequest()); } _context.Entry(users).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UsersExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutSchools(int id, SchoolDto schoolDto) { if (schoolDto.Id == 0) { schoolDto.Id = id; } if (id != schoolDto.Id) { return(BadRequest()); } var school = await _context.Schools.FirstOrDefaultAsync(_ => _.Id == schoolDto.Id); if (school == null) { return(NotFound()); } if (schoolDto.Name != null) { school.Name = schoolDto.Name; } if (schoolDto.Display != null) { school.Display = schoolDto.Display.Value; } school.DateModified = DateTime.Now; _context.Entry(school).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { throw; } return(RedirectToAction("GetSchools", new { id = schoolDto.Id })); }
public async Task <Tuple <Proposal, string> > UpdateProposal(ProposalDto proposalDto) { var proposal = await _dbContext.Proposals.FirstOrDefaultAsync(_ => _.Id == proposalDto.Id); if (proposal != null) { _mapper.Map <ProposalDto, Proposal>(proposalDto, proposal); var stageTuple = await GetStage(proposalDto.StageId, proposalDto.Stage); if (stageTuple?.Item2 != null) { return(new Tuple <Proposal, string>(null, stageTuple.Item2)); } else if (stageTuple?.Item1 != null) { proposal.Stage = stageTuple.Item1; } var deadlineTuple = await GetDeadline(proposalDto.DeadlineId, proposalDto.Deadline); if (deadlineTuple?.Item2 != null) { return(new Tuple <Proposal, string>(null, deadlineTuple.Item2)); } else if (deadlineTuple?.Item1 != null) { proposal.Deadline = deadlineTuple.Item1; } _dbContext.Entry(proposal).State = EntityState.Modified; await _dbContext.SaveChangesAsync(); } return(new Tuple <Proposal, string>(proposal, null)); }