public List <User> GetAllUsers() { using (Proiect2020Container context = new Proiect2020Container()) { return(context.Users.ToList()); }; }
public List <Data> GetAllData() { using (Proiect2020Container context = new Proiect2020Container()) { return(context.Datas.ToList()); }; }
public Data GetDataById(int dataID) { using (Proiect2020Container context = new Proiect2020Container()) { var data = context.Datas.FirstOrDefault(d => d.DataID == dataID); return(data); }; }
public User GetUserById(int userId) { using (Proiect2020Container context = new Proiect2020Container()) { var user = context.Users.FirstOrDefault(u => u.UserID == userId); return(user); }; }
public Data FavoritesData(int dataID, bool favoriteData = true) { using (Proiect2020Container context = new Proiect2020Container()) { var data = context.Datas.FirstOrDefault(d => d.DataID == dataID); data.FavoriteData = favoriteData; context.SaveChanges(); return(data); } }
public bool DeleteData(int dataID) { using (Proiect2020Container context = new Proiect2020Container()) { var data = context.Datas.FirstOrDefault(d => d.DataID == dataID); context.Datas.Remove(data); context.SaveChanges(); return(true); }; }
public bool DeleteSpecialProperty(int propertyID) { using (Proiect2020Container context = new Proiect2020Container()) { var specialProperty = context.SpecialProperties.FirstOrDefault(sp => sp.PropertyID == propertyID); context.SpecialProperties.Remove(specialProperty); context.SaveChanges(); return(true); }; }
public bool DeleteUser(int userId) { using (Proiect2020Container context = new Proiect2020Container()) { var user = context.Users.FirstOrDefault(u => u.UserID == userId); context.Users.Remove(user); context.SaveChanges(); return(true); }; }
public Data MoveData(int dataID, string path, bool movedData = true) { using (Proiect2020Container context = new Proiect2020Container()) { var data = context.Datas.FirstOrDefault(d => d.DataID == dataID); data.Path = path; data.MovedData = movedData; context.SaveChanges(); return(data); } }
public SpecialProperty UpdateSpecialProperty(int propertyID, string propertyName, string propertyDescription) { using (Proiect2020Container context = new Proiect2020Container()) { var specialProperty = context.SpecialProperties.FirstOrDefault(sp => sp.PropertyID == propertyID); specialProperty.PropertyName = propertyName; specialProperty.PropertyDescription = propertyDescription; context.SaveChanges(); return(specialProperty); } }
public bool Login(string email, string password) { using (Proiect2020Container context = new Proiect2020Container()) { var user = context.Users.FirstOrDefault(e => e.Email == email); if (user.Password == password) { return(true); } }; return(false); }
public User UpdateUser(int userId, string firstName, string lastName, string password, string email, string phone) { using (Proiect2020Container context = new Proiect2020Container()) { var user = context.Users.FirstOrDefault(u => u.UserID == userId); user.FirstName = firstName; user.LastName = lastName; user.Password = password; user.Email = email; user.Phone = phone; context.SaveChanges(); return(user); } }
public Data UpdateData(int dataID, string dateType, DateTime creationDate, string eventName, string people, string location, string path) { using (Proiect2020Container context = new Proiect2020Container()) { var data = context.Datas.FirstOrDefault(d => d.DataID == dataID); data.DateType = dateType; data.CreationDate = creationDate; data.EventName = eventName; data.People = people; data.Location = location; data.Path = path; context.SaveChanges(); return(data); } }
public static SpecialProperty CreateSpecialProperty(string propertyName, string propertyDescription) { using (Proiect2020Container context = new Proiect2020Container()) { SpecialProperty specialProperty = new SpecialProperty() { DataID = new Random().Next(1, 20000), PropertyID = new Random().Next(1, 20000), PropertyName = propertyName, PropertyDescription = propertyDescription }; context.SpecialProperties.Add(specialProperty); context.SaveChanges(); return(specialProperty); } }
public static User CreateUser(string firstName, string lastName, string password, string email, string phone) { using (Proiect2020Container context = new Proiect2020Container()) { User myUser = new User() { UserID = new Random().Next(1, 20000), FirstName = firstName, LastName = lastName, Password = password, Email = email, Phone = phone }; context.Users.Add(myUser); context.SaveChanges(); return(myUser); } }
public Data CreateData(string dateType, DateTime creationDate, string eventName, string people, string location, string path) { using (Proiect2020Container context = new Proiect2020Container()) { Data myData = new Data() { DataID = new Random().Next(1, 20000), DateType = dateType, CreationDate = creationDate, EventName = eventName, People = people, Location = location, Path = path, MovedData = false, FavoriteData = true }; context.Datas.Add(myData); context.SaveChanges(); return(myData); } }