Beispiel #1
0
        public async Task <ReturnedSaveFuncInfo> RemoveAsync(SqlTransaction tr = null)
        {
            var           res      = new ReturnedSaveFuncInfo();
            var           autoTran = tr == null;
            SqlConnection cn       = null;

            try
            {
                if (autoTran)
                {
                    cn = new SqlConnection(Cache.ConnectionString);
                    await cn.OpenAsync();

                    tr = cn.BeginTransaction();
                }

                res.AddReturnedValue(await UpdateAccountsAsync(this, true, tr));
                if (res.HasError)
                {
                    return(res);
                }

                var check = await CheckPageBussines.GetAsync(CheckPageGuid);

                check.CheckStatus  = EnCheckSh.Mojoud;
                check.DatePardakht = null;
                check.DateSarresid = null;
                check.Description  = "";
                check.Modified     = DateTime.Now;
                check.Price        = 0;
                check.ReceptorGuid = null;
                res.AddReturnedValue(await check.SaveAsync());
                if (res.HasError)
                {
                    return(res);
                }

                res.AddReturnedValue(await UnitOfWork.PardakhtCheckAvalDore.RemoveAsync(Guid, tr));
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }
            finally
            {
                if (autoTran)
                {
                    res.AddReturnedValue(tr.TransactionDestiny(res.HasError));
                    res.AddReturnedValue(cn.CloseConnection());
                }
            }
            return(res);
        }
Beispiel #2
0
        private static async Task <ReturnedSaveFuncInfo> UpdateAccountsAsync(PardakhtCheckAvalDoreBussines item, bool isRemove, SqlTransaction tr)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                var checkPage = await CheckPageBussines.GetAsync(item.CheckPageGuid);

                var dasteCheck = await DasteCheckBussines.GetAsync(checkPage.CheckGuid);

                var tafsil = await TafsilBussines.GetAsync(dasteCheck.BankGuid);

                var moein = await MoeinBussines.GetAsync(ParentDefaults.MoeinCoding.CLSMoein30101);

                decimal price = 0;
                var     tag   = 1;
                if (isRemove)
                {
                    tag *= -1;
                }

                price = item.Price * tag;

                if (moein == null)
                {
                    res.AddError("حساب معین نامعتبر");
                    return(res);
                }
                if (tafsil == null)
                {
                    res.AddError("حساب تفصیلی نامعتبر");
                    return(res);
                }

                res.AddReturnedValue(await moein.UpdateAccountAsync(price, tr));
                res.AddReturnedValue(await tafsil.UpdateAccountAsync(price, tr));
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }

            return(res);
        }