示例#1
0
        public async Task <AccountTypeDto> Get(int id)
        {
            AccountType entity = await this._unitOfWork.AccountType.Get(id);

            if (!entity.IsVisible)
            {
                return(null);
            }
            AccountTypeDto entityDto = _mapper.Map <AccountTypeDto>(entity);

            return(entityDto);
        }
示例#2
0
        static AccountType MapAccountTypeDto(AccountTypeDto type)
        {
            switch (type)
            {
            case AccountTypeDto.Savings:
                return(AccountType.Savings);

            case AccountTypeDto.Current:
                return(AccountType.Current);

            default:
                throw new NotSupportedException("Employee type is not support.");
            }
        }
示例#3
0
        public ActionResult Saving(string accountdesc1, string accountdesc2)
        {
            RestClient restClient = new RestClient();

            restClient.BaseUrl = new Uri("http://localhost:54178/");
            var restRequest    = new RestRequest($"api/AccountType/SaveAccountType", Method.POST);
            var accountTypeDto = new AccountTypeDto();

            accountTypeDto.accounttype  = "Saving";
            accountTypeDto.accountdesc1 = accountdesc1;
            accountTypeDto.accountdesc2 = accountdesc2;
            restRequest.AddObject(accountTypeDto);
            var result = restClient.Execute(restRequest);

            return(View());
        }
        public IHttpActionResult SaveAccountType(AccountTypeDto accountTypeDto)
        {
            try
            {
                var account = entity.accounts.Where(x => x.accounttype == accountTypeDto.accounttype).First();
                account.accountdesc1 = accountTypeDto.accountdesc1;
                account.accountdesc2 = accountTypeDto.accountdesc2;
                entity.SaveChanges();
                return(Ok(account));
            }
            catch (Exception ex)
            {
                var account = new account
                {
                    accounttype  = accountTypeDto.accounttype,
                    accountdesc1 = accountTypeDto.accountdesc1,
                    accountdesc2 = accountTypeDto.accountdesc2
                };

                entity.accounts.Add(account);
                entity.SaveChanges();
                return(Ok(account));
            }
        }
        public async Task <List <AccountTypeDto> > Get()
        {
            try
            {
                List <AccountTypeDto> accountTypeDtos = new List <AccountTypeDto>();
                var accountTypes = await this._unitOfWork
                                   .AccountType
                                   .GetAll()
                                   .Where(x => x.IsActive & x.IsVisible)
                                   .ToListAsync();

                foreach (var actype in accountTypes)
                {
                    AccountTypeDto accountTypeDto = _mapper.Map <AccountTypeDto>(actype);
                    accountTypeDtos.Add(accountTypeDto);
                }

                return(accountTypeDtos);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }