public Orders(Users user, DateTime orderDate, decimal summaryPrice, DeliveryTypes deliveryType, OrderState orderState) { User = user; OrderDate = orderDate; SummaryPrice = summaryPrice; DeliveryType = deliveryType; State = orderState; }
public void Delete(Users user) { using (_session.BeginTransaction()) { _session.Delete(user); _session.Transaction.Commit(); } }
public static bool IsValid(Users user, string password) { var isValid = false; var crypto = new SimpleCrypto.PBKDF2 {Salt = user.PasswordSalt}; var enteredPassword = crypto.Compute(password); if (enteredPassword == user.Password) isValid = true; return isValid; }
public static bool IsValid(Users user, string password) { bool isValid = false; var crypto = new SimpleCrypto.PBKDF2(); if (user.Password == crypto.Compute(password,user.PasswordSalt)) { isValid = true; } return isValid; }
/// <summary> /// Update a user. /// </summary> /// <param name="user">The user with changed values</param> public async Task <Domain.Models.Users> UpdateUserAsync(int id, Domain.Models.Users user) { _logger.LogInformation("Updating user with ID {userId}", id); DataAccess.Entities.Users currentEntity = await _dbContext.Users.FindAsync(id); var newEntity = Mapper.MapUsers(user); newEntity.Id = id; _dbContext.Entry(currentEntity).CurrentValues.SetValues(newEntity); return(user); }
/// <summary> /// Get a user by ID. /// </summary> /// <returns>The user</returns> public async Task <Domain.Models.Users> GetUserByIdAsync(int userId) { DataAccess.Entities.Users item = await _dbContext.Users .FirstOrDefaultAsync(u => u.Id == userId); if (item is null) { return(null); //throw new ArgumentException("User does not exist"); } return(Mapper.MapUsers(item)); }
public static Library.Models.User MapUsers(Entities.Users users) { return(new Library.Models.User { UserID = users.UserID, Username = users.Username, Password = users.Password, FirstName = users.FirstName, LastName = users.LastName, Email = users.Email, Gender = users.Gender }); }
/// <summary> /// Maps an Entity Framework user DAO to a business model, /// </summary> /// <param name="u">The user DAO.</param> /// <returns>The user business model.</returns> public static Domain.Models.Users MapUsers(Entities.Users u) { return(u is null ? null : new Domain.Models.Users { Id = u.Id, FirstName = u.FirstName, LastName = u.LastName, Address = u.Address, City = u.City, State = u.State, Email = u.Email, Password = u.Password, PhoneNumber = u.PhoneNumber }); }
public bool IsSuccessedCreatedUser(RegisterModel model, string enryptPass, string address, bool isAdmin, string passwordSalt, string ipaddress) { var user = new Users(model.Name, model.Surname, model.Email, enryptPass, model.City, address, model.ZipCode, isAdmin, passwordSalt, ipaddress); try { _userRepo.Save(user); return true; } catch { return false; } }
public void Save(Users entity) { using (ISession session = _connection.CreateSessionFactory().OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { try { session.SaveOrUpdate(entity); transaction.Commit(); } catch (Exception) { transaction.Rollback(); } } } }
public void AuthenticateUser(string username, string password) { UsersRepository userRepo = new UsersRepository(); LoggedUser = userRepo.GetAll(u => u.Username == username && u.Password == password).FirstOrDefault(); }
public void SaveUser() { string password = "******"; var crypto = new PBKDF2(); string enryptPass = crypto.Compute(password); string Email = "*****@*****.**"; string City = "WWA"; string Address = "Sik 41/12"; bool IsAdmin = false; string Name = "Name"; string Surname = "Surname"; string ipAddress = "102.154.12.12"; string ZipCode = "12-222"; string Password = enryptPass; string PasswordSalt = crypto.Salt; var user = new Users(Name, Surname, Email, Password, City, Address, ZipCode, IsAdmin, PasswordSalt, ipAddress); var userGuid = user.ID; Assert.IsNotNull(user); _userRepository.Save(user); Assert.AreNotEqual(userGuid,user.ID); }