public async Task <bool> UpdateAccountCampaignCharge(int accountid, AccountCampaignChargeViewModel model) { if (model.Id == 0) { var accountCharge = new AccountCampaignCharge() { AccountId = accountid, Type = model.Type, //AccountChargeAmount = 20000 //AccountChargeAmount = model.AccountChargeAmount }; await _accountCampaignChargeRepository.AddAsync(accountCharge); } else { var accountCharge = await _accountCampaignChargeRepository.GetByIdAsync(model.Id); if (accountCharge == null || accountCharge.AccountId != accountid) { return(false); } //accountCharge.AccountChargeAmount = model.AccountChargeAmount; //accountCharge.AccountChargeAmount = 20000; await _accountCampaignChargeRepository.UpdateAsync(accountCharge); } return(true); }
public async Task <List <AccountCampaignChargeViewModel> > GetAccountCampaignCharges(int accountid) { var filter = new AccountCampaignChargeByAccountSpecification(accountid); var accountCampaignCharges = await _accountCampaignChargeRepository.ListAsync(filter); return(AccountCampaignChargeViewModel.GetList(accountCampaignCharges)); }
public async Task <bool> UpdateAccountCampaignCharge(int accountid, AccountCampaignChargeViewModel model) { if (model.Id == 0) { var accountCharge = new AccountCampaignCharge() { AccountId = accountid, Type = model.Type, Min = model.Min, Kpi = model.Kpi, Max = model.Max }; await _accountCampaignChargeRepository.AddAsync(accountCharge); } else { var accountCharge = await _accountCampaignChargeRepository.GetByIdAsync(model.Id); if (accountCharge == null || accountCharge.AccountId != accountid) { return(false); } await _accountCampaignChargeRepository.DeleteAsync(accountCharge); var _accountCharge = new AccountCampaignCharge() { AccountId = accountid, Type = model.Type, Min = model.Min, Kpi = model.Kpi, Max = model.Max }; await _accountCampaignChargeRepository.AddAsync(_accountCharge); } return(true); }