Ejemplo n.º 1
0
        /// <summary>
        /// gets specified item by id -calls to stp that if id not specified gets all items
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <ItemEntity> GetById(int?id)
        {
            id = (id != 0) ? id : null;
            var idParam = new SqlParameter("@id", id);

            using (var db = new ItemDBContext())
            {
                var result = await db.ItemEntity.FromSqlRaw("exec [dbo].[GetItems] @id", idParam).AsNoTracking().ToListAsync();

                return(result.FirstOrDefault());
            }
        }
Ejemplo n.º 2
0
        private void CreateTransOnDB(List <IEnumerable <BankTran> > List)
        {
            //try
            //{
            using (ItemDBContext dbContext = new ItemDBContext())
            {
                foreach (var subList in List)
                {
                    //Batch batch = CreateBatch(subList);
                    Batch batch = BatchFactory.GetBatch("recovery", subList);

                    BatchDataEntry bde = CreateBatchDataEntry(batch.GlobalBatchID);

                    IEnumerable <Checks>          checks   = CreateChecks(subList, batch);
                    IEnumerable <ChecksDataEntry> checksDE = CreateChecksDataEntry(checks, batch, subList.ToList());
                    IEnumerable <Transactions>    trans    = CreateTransactions(checks, batch);

                    dbContext.Batch.Add((Batch)batch);
                    dbContext.BatchDataEntry.Add(bde);

                    foreach (var tran in trans)
                    {
                        dbContext.Transactions.Add(tran);
                    }

                    foreach (var check in checks)
                    {
                        dbContext.Checks.Add(check);
                    }

                    foreach (var cde in checksDE)
                    {
                        dbContext.ChecksDataEntry.Add(cde);
                    }

                    dbContext.SaveChanges();
                    //lblTrans.Text = dbContext.Database.Log.ToString();
                }
            }
            //}
            //catch
            //{
            //    throw;
            //}
        }
Ejemplo n.º 3
0
        private static int CreateCheckID()
        {
            try
            {
                int globalCheckID;

                using (var dbContext = new ItemDBContext())
                {
                    globalCheckID = dbContext.Checks.Max(c => c.GlobalCheckID);
                }

                return(globalCheckID);
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// creates new item with data
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public async Task <ItemEntity> Create(ItemEntityFile item)
        {
            using (var db = new ItemDBContext())
            {
                string   Name          = item.Name;
                string   Description   = item.Description;
                DateTime SaleStartDate = item.SaleStartDate;
                string   ImageUrl      = item.ImageUrl;
                var      res           = await _repository
                                         .GetStoredProcedure("[dbo].[CreateItem]")
                                         .WithSqlParams(
                    (nameof(Name), Name),
                    (nameof(Description), Description),
                    (nameof(SaleStartDate), SaleStartDate),
                    (nameof(ImageUrl), ImageUrl))
                                         .ExecuteStoredProcedureAsync <ItemEntity>();

                return(res.FirstOrDefault());
            }
        }
Ejemplo n.º 5
0
        public ActionResult AddItem(int Quantity, string itemName)
        {
            ItemDBContext db = new ItemDBContext();



            if (Session["ShoppingCart"] != null)
            {
                ShoppingCart = (List <Products>)Session["ShoppingCart"];
            }
            foreach (Products item in db.Products)
            {
                if (item.ProductName == itemName)
                {
                    for (int i = 0; i < Quantity; i++)
                    {
                        ShoppingCart.Add(item);
                    }
                }
            }
            Session["ShoppingCart"] = ShoppingCart;
            return(RedirectToAction("Shop"));
        }
Ejemplo n.º 6
0
 public ItemController(ItemDBContext db)
 {
     this.db = db;
 }
Ejemplo n.º 7
0
        public void rm(int customer_id)
        {
            RRDBContext        ratedb      = new RRDBContext();
            ItemvalueDBContext itemvaluedb = new ItemvalueDBContext();
            ShopItemDBContext  shopitemdb  = new ShopItemDBContext();
            ItemDBContext      itemdb      = new ItemDBContext();
            Cust_ShopDBContext custshopdb  = new Cust_ShopDBContext();
            shopDBContext      shopdb      = new shopDBContext();
            //Cs_SuDBContext cssudb = new Cs_SuDBContext();
            //CustomersDBContext customerdb = new CustomersDBContext();

            int shop_id;
            var q1 = from a1 in custshopdb.cust_shop where a1.Cust_Id == customer_id select a1;

            foreach (var item1 in q1.ToList())
            {
                shop_id = item1.S_Id;
                var       q2 = from a2 in shopitemdb.shopit where a2.S_Id == shop_id select a2;
                int       item_id;
                Shop_item si;
                foreach (var item2 in q2.ToList())
                {
                    item_id = item2.T_Id;
                    var        q3 = from a3 in itemvaluedb.item_val where item_id == a3.T_Id select a3;
                    Item_value iv;
                    foreach (var item3 in q3.ToList())
                    {
                        iv = item3;
                        itemvaluedb.item_val.Remove(iv);
                        itemvaluedb.SaveChanges();
                    }
                    si = item2;
                    shopitemdb.shopit.Remove(si);
                    shopitemdb.SaveChanges();

                    var   q4 = from a4 in itemdb.item where a4.T_Id == item_id select a4;
                    Items it;
                    foreach (var item4 in q4.ToList())
                    {
                        it = item4;
                        itemdb.item.Remove(it);
                        itemdb.SaveChanges();

                        Item_rate r = ratedb.itrat.Find(it.T_Id);
                        ratedb.itrat.Remove(r);
                        ratedb.SaveChanges();
                    }
                }
                Cust_Shop cs = item1;
                custshopdb.cust_shop.Remove(cs);
                custshopdb.SaveChanges();

                Shop s;
                var  q5 = from a5 in shopdb.shop where a5.S_Id == shop_id select a5;
                foreach (var item5 in q5.ToList())
                {
                    s = item5;
                    shopdb.shop.Remove(s);
                    shopdb.SaveChanges();
                }
            }

            var   q6 = from a6 in db5.cs_su where a6.Customer == customer_id select a6;
            Cs_Su cssu;

            foreach (var item6 in q6.ToList())
            {
                cssu = item6;
                db5.cs_su.Remove(cssu);
                db5.SaveChanges();
            }

            Customers custome = db.customer.Find(customer_id);

            db.customer.Remove(custome);
            db.SaveChanges();
        }
 public STP_Repository(ItemDBContext dbContext) : base(dbContext)
 {
 }
 public STP_Repository(ItemDBContext dbContext)
 {
     _dbContext = dbContext;
 }
Ejemplo n.º 10
0
        private static Batch CreateRecoveryBatch(IEnumerable <BankTran> bankTrans)
        {
            DateTime curDate = DateTime.Now;
            int      globalBatchID;
            double   amount;
            double   totalAmt = 0;
            int      lockboxID;
            int      bankID;
            int      checkCount;
            int      stubCount;

            lockboxID  = bankTrans.Any(x => x.RecoveryPaymentType == "OVP") ? 316 : 306; // overpaid batch or BRI batch
            bankID     = 7;
            checkCount = bankTrans.Count();
            stubCount  = bankTrans.Count();

            using (var dbContext = new ItemDBContext())
            {
                // Key is equal to the current max value plus one
                globalBatchID = dbContext.Batch.Max(b => b.GlobalBatchID) + 1;
            }

            foreach (var tran in bankTrans)
            {
                if (double.TryParse(tran.PaymentAmount, out amount))
                {
                    totalAmt += amount;
                }
                else
                {
                    throw new Exception("Unable to parse transaction amount: " + tran.PaymentAmount);
                }
            }
            Batch batch = new Batch()
            {
                GlobalBatchID                 = globalBatchID,
                BankID                        = bankID,
                LockboxID                     = lockboxID,
                DESetupID                     = null,
                ProcessingDate                = curDate.Date,
                BatchID                       = 203,
                DepositStatus                 = 850,
                BatchCueID                    = 0,// ???,
                CutOffStatus                  = 0,
                BatchMode                     = null,
                SystemType                    = 0,
                Priority                      = 1,
                PrintLabels                   = 1,
                BatchTypeCode                 = 50, // ???,
                BatchTypeSubCode              = 0,
                BatchTypeText                 = null,
                ConsolidationStatus           = 0,
                CARStatus                     = null,
                KFIStatus                     = null,
                FAXStatus                     = null,
                FloatAssignmentStatus         = 0,
                ScanStatus                    = 21,
                DEStatus                      = 0,
                ExtractSequenceNumber         = 0,
                ImageExtractSequenceNumber    = null,
                DepositDate                   = curDate.Date,
                CheckCount                    = checkCount,
                CheckAmount                   = (decimal)totalAmt,
                StubCount                     = stubCount,
                StubAmount                    = (decimal)totalAmt,
                CreationDate                  = curDate,
                BillingTC                     = 0,
                BillingRT                     = 0,
                BillingAccount                = 0,
                BillingSerial                 = 0,
                WorkgroupID                   = 1,
                CurrencyCode                  = null,
                MICRVerifyStatus              = 4,
                DEPrinted                     = null,
                Is2Pass                       = 1,
                UseCar                        = 1,
                NoChecksEnclosed              = 0,
                Rejects                       = 0,
                DepositTicketPrinted          = false,
                DateLastUpdated               = curDate,
                TransportID                   = null,
                TrayID                        = null,
                SubTrayID                     = null,
                UseCustomer                   = 0,
                DepositDDA                    = null,
                EncodeComplete                = null,
                SplitsEnded                   = false,
                SiteCode                      = null,
                BitonalImageRemovalDate       = null, // ist seems this removal dates are a 1 1/2 month later,
                DataRemovalDate               = null,
                ModificationDate              = curDate,
                TransportBatchID              = null,
                GrayScaleImageRemovalDate     = null,
                ColorImageRemovalDate         = null,
                CWDBDataRemovalDate           = null,
                CWDBBitonalImageRemovalDate   = null,
                CWDBGrayScaleImageRemovalDate = null,
                CWDBColorImageRemovalDate     = null,
                BatchName                     = null,
                BatchTypeID                   = Guid.NewGuid(),
                DecisionStatus                = 0,
                AllowDecisioning              = false,
                RequireDEBeforeTwoPass        = false,
                OriginalGlobalBatchID         = null,
                BatchExtractID                = null,
                IsImageExchange               = false,
                CaptureSiteCodeID             = 10,
                BatchSourceKey                = 1,
                NumOLDDaysRolled              = 0,
            };

            return(batch);
        }