示例#1
0
        public ActionResult Create([Bind(Include = "Id,Email,EmailConfirmed,PasswordHash,SecurityStamp,PhoneNumber,PhoneNumberConfirmed,TwoFactorEnabled,LockoutEndDateUtc,LockoutEnabled,AccessFailedCount,UserName")] AspNetUser aspNetUser)
        {
            if (ModelState.IsValid)
            {
                db.AspNetUsers.Add(aspNetUser);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(aspNetUser));
        }
        public ActionResult Create([Bind(Include = "Id,CategoryName,IsDelete,CreatedOn,CreatedBy")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CreatedBy = new SelectList(db.AspNetUsers, "Id", "Email", category.CreatedBy);
            return(View(category));
        }
示例#3
0
        public ActionResult Create([Bind(Include = "Id,StockId,ProductId,QuantityAdded")] StockDetail stockDetail)
        {
            if (ModelState.IsValid)
            {
                db.StockDetails.Add(stockDetail);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProductId = new SelectList(db.Products, "Id", "ProductDescription", stockDetail.ProductId);
            ViewBag.StockId   = new SelectList(db.Stocks, "Id", "StockName", stockDetail.StockId);
            return(View(stockDetail));
        }
示例#4
0
        public ActionResult Create([Bind(Include = "Id,Name,Contact,Address,EmailId,IsDelete,CreatedBy,CreatedOn,ContactPerson,ContactPersonDesignation")] Supplier supplier)
        {
            if (ModelState.IsValid)
            {
                supplier.CreatedBy = User.Identity.GetUserId();
                supplier.CreatedOn = DateTime.Now;
                db.Suppliers.Add(supplier);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CreatedBy = new SelectList(db.AspNetUsers, "Id", "Email", supplier.CreatedBy);
            return(View(supplier));
        }
示例#5
0
        public ActionResult Create([Bind(Include = "Id,ProductName,CategoryId,CreatedOn,CreatedBy,IsDelete,BarCode,Quantity,StockNo,ProductDescription")] Product product)
        {
            if (ModelState.IsValid)
            {
                product.CreatedBy = User.Identity.GetUserId();
                product.CreatedOn = DateTime.Now;
                db.Products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CreatedBy  = new SelectList(db.AspNetUsers, "Id", "Email", product.CreatedBy);
            ViewBag.CategoryId = new SelectList(db.Categories, "Id", "CategoryName", product.CategoryId);
            return(View(product));
        }
示例#6
0
        public JsonResult SubmitOrder(string CustomerName, int TotalPrice, List <OrderDetail> OrderDetails)
        {
            try
            {
                var Order = new Order();
                Order.BuyerName  = CustomerName;
                Order.BoughtAt   = DateTime.Now;
                Order.CashierId  = User.Identity.GetUserId();
                Order.IsDeleted  = false;
                Order.TotalPrice = TotalPrice;
                db.Orders.Add(Order);

                db.SaveChanges();
                foreach (var item in OrderDetails)
                {
                    OrderDetail detail = new OrderDetail();
                    detail.OrderId   = Order.Id;
                    detail.ProductId = item.ProductId;
                    detail.Quantity  = item.Quantity;
                    detail.Price     = item.Price;

                    var thisProd = db.Products.FirstOrDefault(s => s.Id == item.ProductId);
                    thisProd.Quantity = thisProd.Quantity - item.Quantity;

                    if (thisProd.Quantity < 10)
                    {
                        var newNotification = new Notification();
                        newNotification.GeneratedOn        = DateTime.Now;
                        newNotification.LastUpdated        = DateTime.Now;
                        newNotification.NotificationDetail = "Only " + thisProd.Quantity + " is remaining in Stock of Product " + thisProd.ProductName;
                        newNotification.StatusId           = 1;
                        db.Notifications.Add(newNotification);
                    }

                    db.OrderDetails.Add(detail);
                    db.SaveChanges();
                }
                return(Json("Success", JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json("Something went wrong", JsonRequestBehavior.AllowGet));
            }
        }
示例#7
0
        public ActionResult Create([Bind(Include = "Id,StockName,StockDescription,CreatedBy,CreatedOn,IsDelete,SupplierId")] Stock stock)
        {
            if (ModelState.IsValid)
            {
                db.Stocks.Add(stock);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CreatedBy  = new SelectList(db.AspNetUsers, "Id", "Email", stock.CreatedBy);
            ViewBag.SupplierId = new SelectList(db.Suppliers, "Id", "Name", stock.SupplierId);
            return(View(stock));
        }