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)); }
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)); }
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)); }
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)); }
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)); } }
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)); }