Esempio n. 1
0
        private static async Task <ReturnedSaveFuncInfo> UpdateAccounts(List <SanadDetailBussines> dets, bool isRemove, SqlTransaction tr)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                foreach (var item in dets)
                {
                    var tafsil = await TafsilBussines.GetAsync(item.TafsilGuid);

                    var moein = await MoeinBussines.GetAsync(item.MoeinGuid);

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

                    if (item.Debit > 0)
                    {
                        price = -item.Debit * tag;
                    }
                    else if (item.Credit > 0)
                    {
                        price = item.Credit * tag;
                    }
                    else
                    {
                        res.AddError("مبلغ نامعتبر");
                        return(res);
                    }

                    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);
        }
Esempio n. 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);
        }