public static Users Authenticate(string login, string password) { if (string.IsNullOrEmpty(login)) { return(null); } //if (string.IsNullOrEmpty(password)) return null; Users result = null; using (var db = new DbEntities()) { var q = db.Users.Where(p => (p.Login == login) && (p.Password == password)); if (q.Any()) { result = q.First(); } } return(result); }
public static List <SelectListItem> LoadPossibleParents(DbEntities db, int id) { var list = new List <SelectListItem> { new SelectListItem { Text = "Нет родительской группы", Value = "null" } }; var dbList = LoadAll(db); if (id != 0) { dbList = dbList.Where(p => p.ID != id).ToList(); } foreach (var item in dbList) { list.Add(new SelectListItem { Text = item.Name, Value = item.ID.ToString() }); } return(list); }
//private HttpPostedFileBase _photoUploadedFile { get; set; } //public HttpPostedFileBase PhotoUploadedFile //{ // get { return _photoUploadedFile; } // set // { // _photoUploadedFile = value; // if ((value != null) && (value.ContentLength > 0)) // { // Photo = new byte[value.ContentLength]; // value.InputStream.Read(Photo, 0, Photo.Length); // } // } //} public static List <Products> LoadAll(DbEntities db) { return(db.Products.ToList()); }
public static List <Users> LoadAll(DbEntities db) { return(db.Users.ToList()); }