Ejemplo n.º 1
0
        /// <summary>
        /// Adds emplyee to database
        /// </summary>
        /// <param name="addRequest">Employee add request</param>
        public async Task AddEmployee(EmployeeAddRequest addRequest)
        {
            var newShopUser = Mapper.Map <ShopEmployee>(addRequest);
            await ShopEmployeeRepo.CreateAsync(newShopUser);

            await ShopEmployeeRepo.SaveChangesAsync();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Activates or deactivates employee
        /// </summary>
        /// <param name="employeeId">Emplyee id</param>
        /// <param name="isActive">True to activate</param>
        /// <returns>True if successful</returns>
        public async Task <bool> SetIsActive(Guid employeeId, bool isActive)
        {
            var employeeDb = await ShopEmployeeRepo
                             .GetAll()
                             .FirstOrDefaultAsync(e => e.Id == employeeId);

            if (employeeDb == null)
            {
                return(false);
            }

            employeeDb.IsActive = isActive;

            ShopEmployeeRepo.Update(employeeDb);

            await ShopEmployeeRepo.SaveChangesAsync();

            return(true);
        }