Beispiel #1
0
        private void DeleteFarmAccount(SafeDTO entity)
        {
            var farmAccount = GetFarmAccountBySafeId(entity.Id);

            if (farmAccount != null)
            {
                _farmAccountDSL.Delete(farmAccount.Id);
            }
        }
Beispiel #2
0
        private void DeleteStationAccount(SafeDTO entity)
        {
            var stationAccount = GetStationAccountBySafeId(entity.Id);

            if (stationAccount != null)
            {
                _stationAccountDSL.Delete(stationAccount.Id);
            }
        }
Beispiel #3
0
        private void DeleteSelectorAccount(SafeDTO entity)
        {
            var selectorAccount = GetSelectorAccountBySafeId(entity.Id);

            if (selectorAccount != null)
            {
                _selectorAccountDSL.Delete(selectorAccount.Id);
            }
        }
Beispiel #4
0
        private void DeleteReaperAccount(SafeDTO entity)
        {
            var reaperAccount = GetReaperAccountBySafeId(entity.Id);

            if (reaperAccount != null)
            {
                _reaperAccountDSL.Delete(reaperAccount.Id);
            }
        }
Beispiel #5
0
        private void DeleteDriverAccount(SafeDTO entity)
        {
            var driverAccount = GetDriverAccountBySafeId(entity.Id);

            if (driverAccount != null)
            {
                _driverAccountDSL.Delete(driverAccount.Id);
            }
        }
Beispiel #6
0
        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));
        }
Beispiel #7
0
        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));
        }
Beispiel #8
0
        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));
        }
Beispiel #9
0
        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));
        }
Beispiel #10
0
        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));
        }
Beispiel #11
0
        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));