public SecurityUserAuth ValidateUser(User user) { SecurityUserAuth ret = new SecurityUserAuth(); User authUser = null; using (var db = new BTAContext()) { // Attempt to validate user authUser = db.User.FirstOrDefault(u => u.UserName.ToLower() == user.UserName.ToLower() && u.Password == user.Password); if (authUser != null) { db.Entry(authUser).Collection(x => x.UserClaim).Load(); foreach (var uc in authUser.UserClaim) { db.Entry(uc).Reference(x => x.Claim).Load(); } } } if (authUser != null) { // Build User Security Object ret = BuildUserAuthObject(authUser); } return(ret); }
public async Task <IHttpActionResult> PutStop(int id, Stop stop) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != stop.ID) { return(BadRequest()); } db.Entry(stop).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StopExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }