示例#1
0
 public List <User> GetAllUsers()
 {
     using (Proiect2020Container context = new Proiect2020Container())
     {
         return(context.Users.ToList());
     };
 }
示例#2
0
 public List <Data> GetAllData()
 {
     using (Proiect2020Container context = new Proiect2020Container())
     {
         return(context.Datas.ToList());
     };
 }
示例#3
0
 public Data GetDataById(int dataID)
 {
     using (Proiect2020Container context = new Proiect2020Container())
     {
         var data = context.Datas.FirstOrDefault(d => d.DataID == dataID);
         return(data);
     };
 }
示例#4
0
 public User GetUserById(int userId)
 {
     using (Proiect2020Container context = new Proiect2020Container())
     {
         var user = context.Users.FirstOrDefault(u => u.UserID == userId);
         return(user);
     };
 }
示例#5
0
 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);
     }
 }
示例#6
0
 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);
     };
 }
示例#7
0
 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);
     };
 }
示例#8
0
 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);
     };
 }
示例#9
0
 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);
     }
 }
示例#10
0
 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);
     }
 }
示例#11
0
 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);
 }
示例#12
0
 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);
     }
 }
示例#13
0
 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);
     }
 }
示例#14
0
        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);
            }
        }
示例#15
0
 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);
     }
 }
示例#16
0
 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);
     }
 }