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; } } }
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; } } }
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; } } }
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; } } }