public async Task <IHttpActionResult> PutAction(Guid id, CHM.Services.Models.Action action) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != action.ID) { return(BadRequest()); } db.Entry(action).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ActionExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public Task UpdateAsync(User user) { context.Users.Attach(user); context.Entry(user).State = EntityState.Modified; context.Configuration.ValidateOnSaveEnabled = false; return(context.SaveChangesAsync()); }
public Task UpdateAsync(Role role) { context.Roles.Attach(role); context.Entry(role).State = EntityState.Modified; context.Configuration.ValidateOnSaveEnabled = false; return(context.SaveChangesAsync()); }
public async Task <User> FindUserByEmailAndPassword(string email, string password) { var objUser = context.Users.Include("Users_Roles").Include("Users_Organizations").Include("Users_Roles.Role").Where(obj => obj.Email.Equals(email) && obj.Password.Equals(password)).FirstOrDefault(); if (objUser != null) { DateTime?oldLogin = objUser.LastLogin; var LastLogin = Convert.ToDateTime(DateTime.Now); objUser.LastLogin = LastLogin.ToUniversalTime(); context.Users.Attach(objUser); context.Entry(objUser).State = System.Data.Entity.EntityState.Modified; await context.SaveChangesAsync(); objUser.LastLogin = oldLogin; return(objUser); } return(null); }