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
     });
 }
Exemple #2
0
 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()
     });
 }
Exemple #3
0
        /// <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);
        }
Exemple #4
0
        /// <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);
        }