Exemplo n.º 1
0
        public JsonResult InsertInvoicePurchase(string UserBizCode, string TotalPrice)
        {
            var DbUser = _context.Tbl_User.SingleOrDefault(u => u.BIZCode == UserBizCode);


            PersianDateTime now        = PersianDateTime.Now;
            var             ShamsiDate = now.ToString();

            DateTime MiladiDate = DateTime.Now;

            var Invoice = new Tbl_Invoices {
                UserID = DbUser.Id, SellerID = Convert.ToInt32(Session["UserId"]), DateTime = ShamsiDate, InvoiceStatesID = 1, Description = "خرید از فروشگاه سیرجان"
            };

            var Purchase = new Tbl_SirjanPurchase {
                UserId = DbUser.Id, PurchaseId = 1, Price = TotalPrice, DateTime = ShamsiDate, MiladiDate = MiladiDate, Description = "خرید از فروشگاه سیرجان"
            };

            _context.Tbl_Invoices.Add(Invoice);
            _context.SaveChanges();

            _context.Tbl_SirjanPurchase.Add(Purchase);
            _context.SaveChanges();

            int LastInvoiceId = _context.Database.SqlQuery <int>(@"select top 1 Id from Tbl_Invoices order by Id desc").FirstOrDefault <int>();

            return(Json(LastInvoiceId.ToString(), JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public JsonResult InsertUserBalance(string UserId, string BalancePrice, string Temp)
        {
            PersianDateTime now      = PersianDateTime.Now;
            var             DateTime = now.ToString();

            var Purchase = new Tbl_SirjanPurchase {
            };

            if (Temp == "Increase")
            {
                Purchase = new Tbl_SirjanPurchase {
                    UserId = Convert.ToInt32(UserId), PurchaseId = 3, Price = BalancePrice, DateTime = DateTime, Description = "افزایش سهام کاربر"
                };
            }
            else if (Temp == "Decrease")
            {
                Purchase = new Tbl_SirjanPurchase {
                    UserId = Convert.ToInt32(UserId), PurchaseId = 4, Price = BalancePrice, DateTime = DateTime, Description = "کاهش سهام کاربر"
                };
            }
            _context.Tbl_SirjanPurchase.Add(Purchase);
            _context.SaveChanges();
            return(Json("Successful", JsonRequestBehavior.AllowGet));
        }