Ejemplo n.º 1
0
        public async Task <Result <bool> > Handle(UpdateGateCommand command, CancellationToken cancellationToken)
        {
            try
            {
                var user = await _userRepository.GetUserByEmail(command.ModifiedBy);

                var adminAccess = await _userGateRepository.CheckAdminAccess(command.Id, user.Id);

                if (!adminAccess && !user.Role.Name.Equals("Admin"))
                {
                    return(Result <bool> .AccessDenied("You have no access to modify gate!"));
                }

                var gateType = await _gateTypeRepository.GetGateTypeByName(command.GateTypeName);

                var account = await _accountRepository.GetAccountByName(command.AccountName);

                var currentGate = await _gateRepository.Get(command.Id);

                await UpdateUserGates(command.Id, command.ModifiedBy, command.Users);

                UpdateGateProperties(currentGate, command, gateType, account);

                var res = await _gateRepository.Update(currentGate);

                return(Result <bool> .Ok(res));
            }
            catch (Exception e)
            {
                return(Result <bool> .Failure(e.Message));
            }
        }
Ejemplo n.º 2
0
 public void UpdateGate(Gate gate)
 {
     _gateRepository.Update(gate);
     SaveGate();
 }