Ejemplo n.º 1
0
        public long AddNewFtpCredential(FtpCredentialCreateEditModel model)
        {
            var dto = _mapper.Map <FtpCredential>(model);

            dto.MasterAccounts.Clear();

            if (_ftpCredentialRepository.IsExists(dto))
            {
                throw new FtpCredentialAlreadyExistsException();
            }

            model.MasterAccounts.ToList().ForEach(acc =>
            {
                var masterAcc = _masterAccountRepository.GetById(acc.Id);
                if (masterAcc == null)
                {
                    throw new MasterAccountNotFoundException();
                }
                dto.MasterAccounts.Add(masterAcc);
            });

            dto = _ftpCredentialRepository.Add(dto);

            return(dto.Id);
        }
Ejemplo n.º 2
0
        public long DeleteMasterAccount(long id)
        {
            if (!_masterAccountRepository.IsExists(new MasterAccount {
                Id = id
            }))
            {
                throw new MasterAccountNotFoundException();
            }

            var account = _masterAccountRepository.GetById(id);

            account.Deleted     = true;
            account.UpdatedById = _identityService.GetIdentityId();

            _masterAccountRepository.Update(account);

            return(id);
        }