private void DeleteFarmAccount(SafeDTO entity) { var farmAccount = GetFarmAccountBySafeId(entity.Id); if (farmAccount != null) { _farmAccountDSL.Delete(farmAccount.Id); } }
private void DeleteStationAccount(SafeDTO entity) { var stationAccount = GetStationAccountBySafeId(entity.Id); if (stationAccount != null) { _stationAccountDSL.Delete(stationAccount.Id); } }
private void DeleteSelectorAccount(SafeDTO entity) { var selectorAccount = GetSelectorAccountBySafeId(entity.Id); if (selectorAccount != null) { _selectorAccountDSL.Delete(selectorAccount.Id); } }
private void DeleteReaperAccount(SafeDTO entity) { var reaperAccount = GetReaperAccountBySafeId(entity.Id); if (reaperAccount != null) { _reaperAccountDSL.Delete(reaperAccount.Id); } }
private void DeleteDriverAccount(SafeDTO entity) { var driverAccount = GetDriverAccountBySafeId(entity.Id); if (driverAccount != null) { _driverAccountDSL.Delete(driverAccount.Id); } }
private async Task <long> SaveStationAccount(SafeDTO entity) { StationAccountDTO stationAccount = new StationAccountDTO() { SafeId = entity.Id, PaidDate = entity.Date, PaidUp = entity.Incoming, RecieptNumber = entity.RecieptNumber, StationId = entity.AccountId }; return(await _stationAccountDSL.Save(stationAccount)); }
private async Task <long> SaveReaperAccount(SafeDTO entity) { ReaperAccountDTO reaperAccount = new ReaperAccountDTO() { SafeId = entity.Id, PaidDate = entity.Date, PaidUp = entity.Outcoming, RecieptNumber = entity.RecieptNumber, ReaperId = entity.AccountId }; return(await _reaperAccountDSL.Save(reaperAccount)); }
private async Task <long> SaveSelectorAccount(SafeDTO entity) { SelectorAccountDTO selectorAccount = new SelectorAccountDTO() { SafeId = entity.Id, PaidDate = entity.Date, PaidUp = entity.Outcoming, RecieptNumber = entity.RecieptNumber, SelectorId = entity.AccountId }; return(await _selectorAccountDSL.Save(selectorAccount)); }
private async Task <long> SaveDriverAccount(SafeDTO entity) { DriverAccountDTO driverAccount = new DriverAccountDTO() { SafeId = entity.Id, PaidDate = entity.Date, PaidUp = entity.Outcoming, RecieptNumber = entity.RecieptNumber, DriverId = entity.AccountId }; return(await _driverAccountDSL.Save(driverAccount)); }
private async Task <long> SaveFarmAccount(SafeDTO entity) { FarmAccountDTO farmAccount = new FarmAccountDTO() { SafeId = entity.Id, PaidDate = entity.Date, PaidUp = entity.Outcoming, RecieptNumber = entity.RecieptNumber, FarmId = entity.AccountId }; return(await _farmAccountDSL.Save(farmAccount)); }
public async Task <long> Save(SafeDTO entity) { try { if (entity.Id > 0) { _ISEDITMODE = true; DeleteFarmAccount(entity); DeleteDriverAccount(entity); DeleteReaperAccount(entity); DeleteSelectorAccount(entity); DeleteStationAccount(entity); } entity.Id = await _safeDAL.Save(_mapper.Map <Safe>(entity)); switch (entity.AccountTreeType) { case AccountTreeEnum.Suppliers: await SaveFarmAccount(entity); break; case AccountTreeEnum.Clients: await SaveStationAccount(entity); break; case AccountTreeEnum.Drivers: await SaveDriverAccount(entity); break; case AccountTreeEnum.Reapers: await SaveReaperAccount(entity); break; case AccountTreeEnum.Selectors: await SaveSelectorAccount(entity); break; } return(entity.Id); } catch (Exception ex) { return(0); } }
public async Task <IActionResult> Save(SafeDTO model) => Ok(await _safeDSL.Save(model));