public static bool LogIn(string eMail, string password) { using (var db = new LilHelperEntities()) { return(db.User.Any(user => user.EMail.Equals(eMail, StringComparison.OrdinalIgnoreCase) && user.Password == password)); } }
public HttpResponseMessage NewUser(NewUser newUser) { if (!ModelState.IsValid) { return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState.Select(x => x.Value.Errors) .Where(y => y.Count > 0) .ToList())); } // Create a new user if not existing using (var db = new LilHelperEntities()) { if (db.User.Any(user => user.EMail.Equals(newUser.Email, StringComparison.OrdinalIgnoreCase))) { return(Request.CreateResponse(HttpStatusCode.Conflict, "User allready exists")); } else { try { db.User.Add(new User() { EMail = newUser.Email, Password = newUser.Password }); db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, "User created")); } catch (Exception e) { return(Request.CreateResponse(HttpStatusCode.ServiceUnavailable, "Please try again later")); } } } }
public static bool LogIn(string userName, string password) { using (var db = new LilHelperEntities()) { } }