Beispiel #1
0
 internal static void CreateCreditorStatementFromDeposit(FleetManager.Shared.Models.creditor_depositC _dep, BaseContext _db)
 {
     try
     {
         //
     }
     catch (SqlException ex)
     {
         LoggerX.LogException(ex);
     }
     catch (DbException ex)
     {
         LoggerX.LogException(ex);
     }
     catch (Exception ex)
     {
         LoggerX.LogException(ex);
     }
 }
Beispiel #2
0
 internal static void DeleteCreditorDeposit(FleetManager.Shared.Models.creditor_depositC _dep, BaseContext _db)
 {
     if (_dep == null)
     {
         return;
     }
     try
     {
     }
     catch (SqlException ex)
     {
         LoggerX.LogException(ex);
     }
     catch (DbException ex)
     {
         LoggerX.LogException(ex);
     }
     catch (Exception ex)
     {
         LoggerX.LogException(ex);
     }
 }
Beispiel #3
0
        public Task <bool> DeleteCreditorDeposit(int cr_deposit_id)
        {
            bool _record_deleted = false;

            FleetManager.Shared.Models.creditor_depositC _deposit = null;
            try
            {
                using (var _db = fnn.GetDbContext())
                {
                    _deposit = _db.CREDITOR_DEPOSITS.Where(e => e.cr_deposit_id == cr_deposit_id & e.delete_id == 0).FirstOrDefault();
                    if (_deposit == null)
                    {
                        AddErrorMessage("Error", "Error", "Unable To Find Deposit Object");
                        _record_deleted = false;
                        return(Task.FromResult(_record_deleted));
                    }
                    else
                    {
                        var _result = DbHelper.DeleteRecordWithDeleteId(new DbHelperDeleteRecordC()
                        {
                            pk_col_name = "cr_deposit_id",
                            pk_id       = _deposit.cr_deposit_id,
                            table_name  = DbHelper.GetTableSchemaName(FleetManager.DbBase.tableNames.creditor_deposit_tb)
                        }, _db);
                        if (_result == null || _result == false)
                        {
                            AddErrorMessage("Delete Error", "Delete Error", "Error Encountered While Trying To Delete Record");
                            _record_deleted = false;
                            return(Task.FromResult(_record_deleted));
                        }
                        else
                        {
                            _record_deleted = true;
                            _db.SaveChanges();
                        }
                        var _creditor = (from c in _db.CREDITORS_SET
                                         where c.cr_account_id == _deposit.cr_account_id & c.delete_id == 0
                                         select c).FirstOrDefault();
                        if (_creditor != null)
                        {
                            var _last_deposit = (from k in _db.CREDITOR_DEPOSITS
                                                 where k.delete_id == 0
                                                 orderby k.deposit_fs_id descending, k.cr_deposit_id
                                                 select k).FirstOrDefault();
                            if (_last_deposit != null)
                            {
                                _creditor.last_cr_deposit_id = _last_deposit.cr_deposit_id;
                                _creditor.last_pay_date      = _last_deposit.deposit_date;
                            }
                            else
                            {
                                _creditor.last_cr_deposit_id = 0;
                                _creditor.last_pay_date      = null;
                            }
                            _creditor.fs_timestamp = fnn.GetUnixTimeStamp();
                            //
                            _db.CREDITORS_SET.AddOrUpdateExtension(_creditor);
                            _db.SaveChanges();
                        }
                    }
                }
            }
            catch (SqlException ex)
            {
                LoggerX.LogException(ex);
            }
            catch (DbException ex)
            {
                LoggerX.LogException(ex);
            }
            catch (Exception ex)
            {
                LoggerX.LogException(ex);
            }
            if (_record_deleted)
            {
                Task.Run(() =>
                {
                    using (var _db = fnn.GetDbContext())
                    {
                        //var _creditor = (from k in _db.CREDITORS_SET
                        //                 where k.cr_account_id == _deposit.cr_account_id & k.delete_id == 0
                        //                 select k).FirstOrDefault();
                        //if (_creditor != null)
                        //{
                        //    _deposit = (from k in _db.CREDITOR_DEPOSITS
                        //                where k.cr_account_id == _creditor.cr_account_id & k.delete_id == 0
                        //                orderby k.deposit_fs_id descending, k.cr_deposit_id
                        //                select k).FirstOrDefault();
                        //}
                        fnn.DeleteCreditorDeposit(_deposit, _db);
                        _db.SaveChanges();
                    }
                });
            }
            return(Task.FromResult(_record_deleted));
        }