public async Task <int> UpdateUserAsync(User user) { User u = await GetUserByEmailAsync(user.Email); if (u != null) { if (u.Id != user.Id) { return(-1); // If email alreay assigned to other user } Context.Entry(u).State = EntityState.Detached; // To be able to attach user } Context.Entry(user).State = EntityState.Modified; return(await Context.SaveChangesAsync()); }
public async Task <int> UpdateRunAsync(Run run) { Context.Entry(run).State = EntityState.Modified; return(await Context.SaveChangesAsync()); }