示例#1
0
        public void Start()
        {
            using (var dbEntities = new DBEntities())
            {

            }
        }
示例#2
0
文件: PointRepo.cs 项目: xpss/remote
 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
文件: UserRepo.cs 项目: xpss/remote
 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
文件: UserRepo.cs 项目: xpss/remote
 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
文件: PointRepo.cs 项目: xpss/remote
 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
文件: UserRepo.cs 项目: xpss/remote
 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;
         }
     }
 }