public static Models.Users MapUser(Models.Users u) { return(new Models.Users() { UserId = u.UserId, UserName = u.UserName, UserCode = u.UserCode, StoreId = u.StoreId, StoreTime = u.StoreTime }); }
internal static Domain.User Map(Domain.Models.Users login) { if (login == null) { return(null); } return(new Domain.User() { Id = login.Id, Username = login.IdNavigation.Username.Trim() }); }
/// <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> /// Add a useer. /// </summary> /// <param name="user">The user</param> public async void AddUserAsync(Domain.Models.Users user) { if (user.Id != 0) { _logger.LogWarning("User to be added has an ID ({userId}) already: ignoring.", user.Id); } _logger.LogInformation("Adding user"); var entity = Mapper.MapUsers(user); entity.Id = 0; await _dbContext.Users.AddAsync(entity); }