Example #1
0
 public List <User> GetAllUsers()
 {
     using (Proiect2020Container context = new Proiect2020Container())
     {
         return(context.Users.ToList());
     };
 }
Example #2
0
 public List <Data> GetAllData()
 {
     using (Proiect2020Container context = new Proiect2020Container())
     {
         return(context.Datas.ToList());
     };
 }
Example #3
0
 public Data GetDataById(int dataID)
 {
     using (Proiect2020Container context = new Proiect2020Container())
     {
         var data = context.Datas.FirstOrDefault(d => d.DataID == dataID);
         return(data);
     };
 }
Example #4
0
 public User GetUserById(int userId)
 {
     using (Proiect2020Container context = new Proiect2020Container())
     {
         var user = context.Users.FirstOrDefault(u => u.UserID == userId);
         return(user);
     };
 }
Example #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);
     }
 }
Example #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);
     };
 }
Example #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);
     };
 }
Example #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);
     };
 }
Example #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);
     }
 }
Example #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);
     }
 }
Example #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);
 }
Example #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);
     }
 }
Example #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);
     }
 }
Example #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);
            }
        }
Example #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);
     }
 }
Example #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);
     }
 }