Exemplo n.º 1
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;
         }
     }
 }
Exemplo n.º 2
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;
         }
     }
 }
Exemplo n.º 3
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;
         }
     }
 }
Exemplo n.º 4
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;
         }
     }
 }