public async Task <Organisation> AddOrganisationAsync(Organisation organisation) { using (var context = new TimeKeeperDbContext(_options)) { var result = context.Organisation.Add(organisation); await context.SaveChangesAsync(); return(result.Entity); } }
public async Task <ApplicationUser> UpdateApplicationUserAsync(ApplicationUser applicationUser) { using (var _context = new TimeKeeperDbContext(_options)) { _context.AspNetUsers.Update(applicationUser); await _context.SaveChangesAsync(); return(applicationUser); } }
public async Task <Deviation> AddDeviationAsync(Deviation deviation) { using (var _context = new TimeKeeperDbContext(_options)) { var result = _context.Add(deviation); await _context.SaveChangesAsync(); return(result.Entity); } }
public async Task <Invitation> UpdateInvitationAsync(Invitation invitation) { using (var context = new TimeKeeperDbContext(_options)) { context.Invitations.Update(invitation); await context.SaveChangesAsync(); return(invitation); } }
public async Task <WorkMonth> AddWorkMonth(WorkMonth workMonth) { using (var context = new TimeKeeperDbContext(_options)) { var result = context.Add(workMonth); await context.SaveChangesAsync(); return(result.Entity); } }
public async void AddSectionAsync(Organisation section, int parentId) { using (var context = new TimeKeeperDbContext(_options)) { var parent = context.Organisation.Where(o => o.Id == parentId).FirstOrDefault(); if (parent == null) { throw new Exception("Organisation do not exist."); } parent.Section = new List <Organisation>(); parent.Section.Add(section); await context.SaveChangesAsync(); } throw new Exception("Error while adding section."); }