Esempio n. 1
0
 public Transaction RemoveTempAndReturnTransactionGroup(Guid tempId)
 {
     try
     {
         this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
         var tempBo = new TempBO();
         var removeTempAndReturnTransaction = tempBo.RemoveTempAndReturnTransaction(this.ConnectionHandler, tempId);
         var list = tempBo.Where(this.ConnectionHandler, x => x.ParentId == tempId);
         foreach (var temp in list)
         {
             tempBo.RemoveTempAndReturnTransaction(this.ConnectionHandler, temp.Id);
         }
         this.ConnectionHandler.CommitTransaction();
         return(removeTempAndReturnTransaction);
     }
     catch (KnownException ex)
     {
         this.ConnectionHandler.RollBack();
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
     catch (Exception ex)
     {
         this.ConnectionHandler.RollBack();
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
 }
Esempio n. 2
0
 public override bool Delete(params object[] keys)
 {
     try
     {
         this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
         var tempBo = new TempBO();
         if (!tempBo.Delete(this.ConnectionHandler, keys))
         {
             throw new Exception(Resources.Payment.ErrorInDeleteTemp);
         }
         this.ConnectionHandler.CommitTransaction();
         return(true);
     }
     catch (KnownException ex)
     {
         this.ConnectionHandler.RollBack();
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
     catch (Exception ex)
     {
         this.ConnectionHandler.RollBack();
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
 }
Esempio n. 3
0
 public bool Update(Temp temp, List <DiscountType> discountAttaches)
 {
     try
     {
         this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted);
         this.FileManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted);
         var tempBo = new TempBO();
         if (!tempBo.Update(this.ConnectionHandler, temp))
         {
             throw new Exception(Resources.Payment.ErrorInSaveTransaction);
         }
         if (!new TempDiscountBO().ModifyDiscount(this.ConnectionHandler, this.FileManagerConnection, discountAttaches, temp.Id))
         {
             throw new Exception(Resources.Payment.ErrorInSaveTransaction);
         }
         this.ConnectionHandler.CommitTransaction();
         this.FileManagerConnection.CommitTransaction();
         return(true);
     }
     catch (KnownException ex)
     {
         this.ConnectionHandler.RollBack();
         this.FileManagerConnection.RollBack();
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
     catch (Exception ex)
     {
         this.ConnectionHandler.RollBack();
         this.FileManagerConnection.RollBack();
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
 }
Esempio n. 4
0
 public List <Transaction> GetUserTransactions(Guid userId)
 {
     try
     {
         var list         = new List <Transaction>();
         var tempBo       = new TempBO();
         var temps        = tempBo.GetByUserId(this.ConnectionHandler, userId);
         var transactions = new TransactionBO().OrderByDescending(this.ConnectionHandler, x => x.PayDate, x => x.PayerId == userId);
         foreach (var temp in temps)
         {
             var transactionModel = new Transaction()
             {
                 Id          = temp.Id,
                 Amount      = temp.Amount,
                 PayDate     = temp.Date,
                 Description = temp.Description,
                 IsTemp      = true
             };
             list.Add(transactionModel);
         }
         foreach (var transaction in transactions)
         {
             list.Add(transaction);
         }
         return(list);
     }
     catch (KnownException ex)
     {
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
     catch (Exception ex)
     {
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
 }
Esempio n. 5
0
        public List <TempDiscount> GetDiscountTypes(string modualName, byte section, Guid?tempId = null)
        {
            try
            {
                var outlist = new List <TempDiscount>();
                if (tempId.HasValue)
                {
                    var tr = new TempBO().Get(this.ConnectionHandler, tempId);
                    if (tr.TransactionId.HasValue)
                    {
                        return(outlist);
                    }
                }
                var list = new DiscountTypeSectionBO().GetDiscountTypes(this.ConnectionHandler, modualName, section);
                var transactionDiscountBo  = new TempDiscountBO();
                var discountTypeAutoCodeBo = new DiscountTypeAutoCodeBO();
                var discountTypeBo         = new DiscountTypeBO();
                if (!list.Any())
                {
                    return(outlist);
                }
                var enumerable            = list.Select(x => x.Id);
                var discountTypes         = discountTypeBo.Where(ConnectionHandler, x => x.Id.In(enumerable));
                var tempDiscounts         = transactionDiscountBo.Where(ConnectionHandler, x => x.DiscountTypeId.In(enumerable));
                var discountTypeAutoCodes = discountTypeAutoCodeBo.Where(ConnectionHandler, x => x.DiscountTypeId.In(enumerable));

                foreach (var discountType in list)
                {
                    var getdiscountType = discountTypes.FirstOrDefault(x => x.Id == discountType.Id);
                    if (getdiscountType == null)
                    {
                        continue;
                    }
                    if (((!string.IsNullOrEmpty(getdiscountType.EndDate.Trim()) && getdiscountType.EndDate.CompareTo(DateTime.Now.ShamsiDate()) < 0)) ||
                        ((!string.IsNullOrEmpty(getdiscountType.StartDate.Trim()) && getdiscountType.StartDate.CompareTo(DateTime.Now.ShamsiDate()) > 0)) ||
                        string.IsNullOrEmpty(getdiscountType.Title) || !getdiscountType.Enabled)
                    {
                        continue;
                    }
                    TempDiscount tempDiscount;
                    if (tempId.HasValue)
                    {
                        var discount = tempDiscounts.FirstOrDefault(x => x.TempId == tempId && x.DiscountTypeId == discountType.Id);
                        if (discount != null)
                        {
                            tempDiscount       = discount;
                            tempDiscount.Added = true;
                        }
                        else
                        {
                            tempDiscount = new TempDiscount()
                            {
                                DiscountTypeId = discountType.Id
                            }
                        };
                    }
                    else
                    {
                        tempDiscount = new TempDiscount()
                        {
                            DiscountTypeId = discountType.Id
                        }
                    };
                    if (getdiscountType.ForceCode)
                    {
                        if (getdiscountType.IsAutoCode)
                        {
                            var byFilter = discountTypeAutoCodes.Any(x =>
                                                                     x.DiscountTypeId == getdiscountType.Id &&
                                                                     x.Used == false);
                            if (!byFilter)
                            {
                                continue;
                            }
                        }
                        else if (getdiscountType.RemainCapacity == 0)
                        {
                            continue;
                        }
                    }
                    if (!getdiscountType.ForceCode && !getdiscountType.ForceAttach)
                    {
                        tempDiscount.Added = true;
                    }
                    tempDiscount.DiscountType = getdiscountType;
                    outlist.Add(tempDiscount);
                }
                return(outlist);
            }
            catch (KnownException ex)
            {
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
            catch (Exception ex)
            {
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
        }