public JsonResult SetPerson(StoreClerk storeClerk) { PurchaseOrdersController purchaseOrdersController = new PurchaseOrdersController(); purchaseOrdersController.SystemGeneratePO(); StationeryRetrievalFormsController stationeryRetrievalFormsController = new StationeryRetrievalFormsController(); stationeryRetrievalFormsController.GenerateRetrievalForm(); stationeryRetrievalFormsController.MergeRetrievalForms(); StoreClerk storeclerk = db1.StoreClerks.Where(p => p.UserName == storeClerk.UserName).FirstOrDefault(); string hashedPassword = CalculateMD5Hash(storeClerk.Password); if (ModelState.IsValid) { if (storeclerk != null && storeclerk.Password == hashedPassword) { string sessionId = Guid.NewGuid().ToString(); storeclerk.Password = hashedPassword; storeclerk.SessionId = sessionId; db1.Entry(storeclerk).State = EntityState.Modified; db1.SaveChanges(); return(Json(new { sessionId = storeclerk.SessionId, username = storeclerk.UserName, status = "success" })); } else { return(Json(new { status = "fail" })); } } else { return(Json(new { status = "fail" })); } }
public ActionResult Index(string sessionId) { PurchaseOrdersController purchaseOrdersController = new PurchaseOrdersController(); purchaseOrdersController.SystemGeneratePO(); purchaseOrdersController.MergePurchaseOrders(); StationeryRetrievalFormsController stationeryRetrievalFormsController = new StationeryRetrievalFormsController(); stationeryRetrievalFormsController.GenerateRetrievalForm(); stationeryRetrievalFormsController.MergeRetrievalForms(); StoreClerk storeclerk = dbM.StoreClerks.Where(p => p.SessionId == sessionId).FirstOrDefault(); if (storeclerk != null && sessionId != null) { int num = dbM.RequisitionForms.Where(x => x.Status == "Approved").Count(); int numDisbuserment = dbM.DisbursementLists.Where(x => x.Status == "Pending").Count(); int numOutS = dbM.OutstandingLists.Where(x => x.Status == "Awaiting Goods").Count(); int numRetrive = dbM.StationeryRetrievalForms.Where(x => x.Status == "Pending").Count(); int numPO = dbM.PurchaseOrders.Where(x => x.Status == "Not Submitted").Count(); int numStock = dbM.StockAdjustmentVouchers.Where(x => x.Status == "Pending").Count(); ViewData["num"] = num; ViewData["numDisbuserment"] = numDisbuserment; ViewData["numOutSt"] = numOutS; ViewData["numRetriF"] = numRetrive; ViewData["numPO"] = numPO; ViewData["numStockAj"] = numStock; ViewData["sumTotal"] = (num + numDisbuserment + numOutS + numRetrive + numPO + numStock).ToString(); ViewData["sessionId"] = storeclerk.SessionId; ViewData["username"] = storeclerk.UserName; ViewData["tag"] = "storeclerk"; return(View()); } else { return(RedirectToAction("Login", "Login")); } }