Пример #1
0
        public void Start()
        {
            using (var dbEntities = new DBEntities())
            {

            }
        }
Пример #2
0
 public bool Add(PointModel pointModel)
 {
     using (var dbEntities = new DBEntities())
     {
         try
         {
             dbEntities.Points.Add(new Point()
                                       {
                                           UserID = 11,
                                           X = pointModel.X,
                                           Y = pointModel.Y,
                                           Z = pointModel.Z,
                                           vX = pointModel.Xv,
                                           vY = pointModel.Yv,
                                           vZ = pointModel.Zv,
                                           Date = DateTime.Now
                                       });
             dbEntities.SaveChanges();
             return true;
         }
         catch (Exception)
         {
             return false;
         }
     }
 }
Пример #3
0
 public int GetUserIdByName(string firstName, string lastName)
 {
     using (var dbEntities = new DBEntities())
     {
         return dbEntities.Users.First(p => p.FirstName == firstName && p.LastName == lastName).Id;
     }
 }
Пример #4
0
 public int GetCurrentUserId(string login)
 {
     using (var dbEntities = new DBEntities())
     {
         return dbEntities.Credentials.First(p => p.Login == login).UserID;
     }
 }
Пример #5
0
 public bool Login(string login, string password)
 {
     using (var dbEntities = new DBEntities())
     {
         string encryptedPassword = CryptoHelper.Encrypt(password);
         return dbEntities.Credentials.FirstOrDefault(p => p.Login == login && p.Password == encryptedPassword) != null;
     }
 }
Пример #6
0
 public UserModel GetUserById(int id)
 {
     using (var dbEntities = new DBEntities())
     {
         User user = dbEntities.Users.FirstOrDefault(p => p.Id == id);
         return new UserModel()
         {
             UserId = user.Id,
             Address = user.Address,
             Birthday = user.Birthday,
             FirstName = user.FirstName,
             LastName = user.LastName,
             Mobile = user.Mobile
         };
     }
 }
Пример #7
0
 public bool Remove(CredentialsModel credentials)
 {
     using (var dbEntities = new DBEntities())
     {
         try
         {
             dbEntities.Credentials.Remove(new Credential() { Id = credentials.Id, UserID = credentials.UserId, Login = credentials.Login, Password = credentials.Password });
             dbEntities.SaveChanges();
             return true;
         }
         catch (Exception exception)
         {
             return false;
         }
     }
 }
Пример #8
0
 public bool Add(int userId, string login, string password)
 {
     using (var dbEntities = new DBEntities())
     {
         try
         {
             dbEntities.Credentials.Add(new Credential() { Login = login, Password = CryptoHelper.Encrypt(password), UserID = userId });
             dbEntities.SaveChanges();
             return true;
         }
         catch (Exception exception)
         {
             return false;
         }
     }
 }
Пример #9
0
 public IEnumerable<PointModel> GetAllPoint(int id)
 {
     using (var dbEntities = new DBEntities())
     {
         return dbEntities.Points.Where(w => w.UserID == id).Select(p => new PointModel()
                                           {
                                                 //User = p.UserID,
                                                 X = p.X,
                                                 Y = p.Y,
                                                 Z = p.Z,
                                                 Xv = p.vX,
                                                 Yv = p.vY,
                                                 Zv = p.vZ,
                                                 Date = p.Date
                                           }).ToArray();
     }
 }
Пример #10
0
 public int Add(UserModel userModel)
 {
     using (var dbEntities = new DBEntities())
     {
         try
         {
             dbEntities.Users.Add(new User()
                                      {
                                          FirstName = userModel.FirstName,
                                          LastName = userModel.LastName,
                                          Mobile = userModel.Mobile,
                                          Address = userModel.Address,
                                          Birthday = userModel.Birthday
                                      });
             dbEntities.SaveChanges();
             return GetUserIdByName(userModel.FirstName, userModel.LastName);
         }
         catch (Exception e)
         {
             return 0;
         }
     }
 }