public JsonResult GetAllModule() { try { decimal id = SessionManger.WorkShopOfLoggedInUser(Session); string user_id = User.Identity.GetUserId(); var result = unitOfWork.ModuleRepository.Get() .Select(a => new { a.ModuleId, a.ModuleName, a.ModuleIcon, action = a.tblActions.Where(b => b.IsInMenu == true && b.tblUserActionMappings.Where(am => am.user_id == user_id && am.is_permitted == 1).Any()) .Select(ac => new { ac.ActionId, ac.ActionName, ac.ActionDisplayName, ac.ActionUrl } ).ToList() }).Where(a => a.action.Count() > 0).ToList(); return(Json(new { result = result, success = true }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { throw ex; } }
public JsonResult SaveProduct(VM_Product aProduct) { if (ModelState.IsValid) { try { tblProductInformation product = new tblProductInformation(); product.ProductName = aProduct.ProductName; product.ProductTypeId = aProduct.ProductTypeId; product.StoreId = aProduct.StoreId; product.Unit = aProduct.Unit; product.UnitPrice = (decimal)aProduct.UnitPrice; product.ProductionCost = (decimal)aProduct.ProductionCost; product.RestaurantId = Int32.Parse(SessionManger.RestaurantOfLoggedInUser(Session).ToString()); product.CreatedBy = SessionManger.LoggedInUser(Session); product.CreatedDateTime = DateTime.Now; product.EditedBy = null; product.EditedDateTime = null; unitOfWork.ProductRepository.Insert(product); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Product Added Successfully." })); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "Model is not Valid" }, JsonRequestBehavior.AllowGet)); } }
public JsonResult LoadModules() { try { decimal id = SessionManger.RestaurantOfLoggedInUser(Session); string user_id = User.Identity.GetUserId(); var result = unitOfWork.ModuleRepository.Get() .Select(a => new { a.module_id, a.module_name, a.module_icon, action = a.tblActions.Where(b => b.is_in_menu == true && b.tblUserActionMappings.Where(am => am.user_id == user_id && am.is_permitted == 1).Any()) .Select(ac => new { ac.id, ac.name, ac.display_name, ac.url } ).ToList() }).Where(a => a.action.Count() > 0).ToList(); return(Json(new { result = result, success = true }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { throw ex; } }
public ActionResult Update(VM_PartsInfo partsInfo) { if (ModelState.IsValid) { try { tblPartsInfo aPartsInfo = unitOfWork.PartsInfoRepository.GetByID(partsInfo.PartsId); aPartsInfo.PartsName = partsInfo.PartsName; aPartsInfo.BasePrice = partsInfo.BasePrice; aPartsInfo.EditedBy = SessionManger.LoggedInUser(Session); aPartsInfo.EditedDateTime = DateTime.Now; unitOfWork.PartsInfoRepository.Update(aPartsInfo); unitOfWork.Save(); return(Json(new { success = true, successMessage = "parts Info update successfully." }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "Enter All required Field" }, JsonRequestBehavior.AllowGet)); } }
public JsonResult SaveAccGroup(acc_Group aAccGroup) { if (ModelState.IsValid) { try { //Code aAccGroup.OCode = 1; aAccGroup.RestaurantId = Int32.Parse(SessionManger.RestaurantOfLoggedInUser(Session).ToString()); aAccGroup.CreatedBy = SessionManger.LoggedInUser(Session); aAccGroup.CreatedDateTime = DateTime.Now; aAccGroup.EditedBy = null; aAccGroup.EditedDateTime = null; unitOfWork.AccGroupRepository.Insert(aAccGroup); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Account Group added successfully" })); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "Model is not Valid!! Please, Fill up all the fields." }, JsonRequestBehavior.AllowGet)); } }
public JsonResult AddSupplier(VM_Supplier supplier) { if (ModelState.IsValid) { try { tblSupplier aSupplier = new tblSupplier(); aSupplier.CompanyName = supplier.CompanyName; aSupplier.Address = supplier.Address; aSupplier.ContactNo = supplier.ContactNo; aSupplier.WorkShopId = Int32.Parse(SessionManger.WorkShopOfLoggedInUser(Session).ToString()); aSupplier.CreatedBy = SessionManger.LoggedInUser(Session); aSupplier.CreatedDateTime = DateTime.Now; aSupplier.EditedBy = null; aSupplier.EditedDateTime = null; unitOfWork.SupplierRepository.Insert(aSupplier); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Supplier Added Successfully!" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "Fill Up all required filled" }, JsonRequestBehavior.AllowGet)); } }
public async Task <ActionResult> Login(LoginViewModel model, string returnUrl) { TempData["errorMessage"] = string.Empty; if (ModelState.IsValid) { var user = await UserManager.FindAsync(model.UserName, model.Password); if (user != null) { await SignInAsync(user, model.RememberMe); using (RestaurantEntities rc = new RestaurantEntities()) { try { tblRestaurantUser RestaurantUser = new tblRestaurantUser(); var resturant = unitOfWork.RestaurantRepository.Get().Where(x => x.short_name == model.RestaurantName).FirstOrDefault(); RestaurantUser.UserId = user.Id; RestaurantUser.is_loggedIn = 1; RestaurantUser.last_logged_time = DateTime.Now; RestaurantUser.restaurant_id = resturant.restaurant_id; //rc.tblAdminUsers.Attach(RestaurantUser); //var entry = rc.Entry(RestaurantUser); //entry.State = EntityState.Modified; //rc.SaveChanges(); unitOfWork.AdminUserRepository.Update(RestaurantUser); unitOfWork.Save(); SessionManger.SetLoggedInTime(Session, DateTime.Now); SessionManger.SetLoggedInUser(Session, model.UserName, resturant.restaurant_id); return(Redirect("/#Index")); // return Json(new { success = true, successMessage = "Successfully User Created" }); } catch (Exception ex) { return(Redirect("/#Login")); throw; } } //return RedirectToLocal(returnUrl); } else { ModelState.AddModelError("", "Invalid username or password."); TempData["errorMessage"] = "Invalid username or password."; //return View(model); View(model); //System.Threading.Thread.SpinWait(60); return(Redirect("/#Login")); } } // If we got this far, something failed, redisplay form //return View(model); TempData["errorMessage"] = "Invalid username or password."; //return View(model); View(model); //System.Threading.Thread.SpinWait(60); return(Redirect("/#Login")); }
public JsonResult ProductUseInProductionHouse(List <VM_Product> productList) { try { foreach (var product in productList) { tblProductTransfer productTransfer = new tblProductTransfer(); productTransfer.DateTime = DateTime.Now; productTransfer.CreatedBy = SessionManger.LoggedInUser(Session); productTransfer.EditedBy = null; productTransfer.RestaurantId = Int32.Parse(SessionManger.RestaurantOfLoggedInUser(Session).ToString()); productTransfer.CreatedDateTime = DateTime.Now; productTransfer.StoreId = product.StoreId; productTransfer.SupplierId = null; productTransfer.ProductId = product.ProductId; productTransfer.Quantity = product.Quantity; productTransfer.TransferDate = DateTime.Now; productTransfer.isOut = true; productTransfer.Unit = product.Unit; unitOfWork.ProductTransferRepository.Insert(productTransfer); } unitOfWork.Save(); return(Json(new { success = true, successMesseage = "Raw Metarial Taken From ProductionHouse Successfully" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Update(VM_Module module) { if (ModelState.IsValid) { try { tblModule aModule = unitOfWork.ModuleRepository.GetByID(module.ModuleId); aModule.ModuleName = module.ModuleName; aModule.ModuleOrder = module.ModuleOrder; aModule.ModuleIcon = module.ModuleIcon; aModule.EditedBy = SessionManger.LoggedInUser(Session); aModule.EditedDateTime = DateTime.Now; unitOfWork.ModuleRepository.Update(aModule); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Module Info update successfully." }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "Model is not valid" }, JsonRequestBehavior.AllowGet)); } }
public JsonResult AddModule(VM_Module module) { if (ModelState.IsValid) { try { tblModule aModule = new tblModule(); aModule.ModuleName = module.ModuleName; aModule.ModuleOrder = module.ModuleOrder; aModule.ModuleIcon = module.ModuleIcon; aModule.WorkShopId = Int32.Parse(SessionManger.WorkShopOfLoggedInUser(Session).ToString()); aModule.CreatedBy = SessionManger.LoggedInUser(Session); aModule.CreatedDateTime = DateTime.Now; aModule.EditedBy = null; aModule.EditedDateTime = null; unitOfWork.ModuleRepository.Insert(aModule); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Module Added Successfully!" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "Fill Up all required filled" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult AddDesignation(VM_Designation designation) { if (ModelState.IsValid) { try { tblDesignation aDesignation = new tblDesignation(); aDesignation.DesignationName = designation.DesignationName; aDesignation.WorkShopId = Int32.Parse(SessionManger.WorkShopOfLoggedInUser(Session).ToString()); aDesignation.CreatedBy = SessionManger.LoggedInUser(Session); aDesignation.CreatedDateTime = DateTime.Now; aDesignation.EditedBy = null; aDesignation.EditedDateTime = null; unitOfWork.DesignationRepository.Insert(aDesignation); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Designation Save Successfully" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "Designation not Save" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Update(VM_Designation designation) { if (ModelState.IsValid) { try { tblDesignation aDesignation = unitOfWork.DesignationRepository.GetByID(designation.DesignationId); aDesignation.DesignationName = designation.DesignationName; aDesignation.EditedBy = SessionManger.LoggedInUser(Session); aDesignation.EditedDateTime = DateTime.Now; unitOfWork.DesignationRepository.Update(aDesignation); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Designation Info update successfully." }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "Model is not valid" }, JsonRequestBehavior.AllowGet)); } }
public JsonResult UserMenuActionForPermission(string userId) { //decimal id = SessionManger.BrokerOfLoggedInUser(Session).membership_id; decimal workShopId = SessionManger.WorkShopOfLoggedInUser(Session); //string user_id = User.Identity.GetUserId(); //var views = userActionMappingFactory.GetAll().Where(a => a.user_id == user_id) // .Select(x => x.action_id).ToList(); var data = unitOfWork.ModuleRepository.Get() .Select(a => new { a.ModuleId, label = a.ModuleName, children = a.tblActions.Where(x => x.IsInMenu == true) .Select(ac => new { ac.ActionId, label = ac.ActionDisplayName, //a.membership_id, selected = ac.tblUserActionMappings.Where(x => x.user_id == userId).Select(x => x.user_id).FirstOrDefault() == null ? false : true } ).ToList() }).ToList(); return(Json(new { success = true, result = data }, JsonRequestBehavior.AllowGet)); }
public JsonResult AddLedger(VM_AddLedger vmLedger) { try { acc_Ledger ledger = new acc_Ledger(); ledger.LedgerID = Guid.NewGuid(); ledger.LedgerName = vmLedger.LedgerName; ledger.LedgerCode = vmLedger.LedgerCode; ledger.GroupID = vmLedger.GroupID; ledger.InitialBalance = vmLedger.InitialBalance; ledger.BalanceType = vmLedger.BalanceType; ledger.Comment = vmLedger.Comment; ledger.OCode = 1; ledger.RestaurantId = Convert.ToInt32(SessionManger.RestaurantOfLoggedInUser(Session)); ledger.CreatedBy = SessionManger.LoggedInUser(Session); ledger.CreatedDateTime = DateTime.Now; unitOfWork.AccLedgerRepository.Insert(ledger); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Succefully Added Ledger" }, JsonRequestBehavior.AllowGet)); } catch (Exception exception) { return(Json(new { success = false, errorMessage = exception.Message })); } }
public ActionResult Update(VM_Supplier supplier) { if (ModelState.IsValid) { try { tblSupplier aSupplier = unitOfWork.SupplierRepository.GetByID(supplier.SupplierId); aSupplier.CompanyName = supplier.CompanyName; aSupplier.Address = supplier.Address; aSupplier.ContactNo = supplier.ContactNo; aSupplier.EditedBy = SessionManger.LoggedInUser(Session); aSupplier.EditedDateTime = DateTime.Now; unitOfWork.SupplierRepository.Update(aSupplier); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Supplier Info update successfully." }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "Enter All required Field" }, JsonRequestBehavior.AllowGet)); } }
public JsonResult AddPartsInfo(VM_PartsInfo partsInfo) { if (ModelState.IsValid) { try { tblPartsInfo aPartsInfo = new tblPartsInfo(); aPartsInfo.PartsName = partsInfo.PartsName; aPartsInfo.BasePrice = partsInfo.BasePrice; aPartsInfo.WorkShopId = Int32.Parse(SessionManger.WorkShopOfLoggedInUser(Session).ToString()); aPartsInfo.CreatedBy = SessionManger.LoggedInUser(Session); aPartsInfo.CreatedDateTime = DateTime.Now; aPartsInfo.EditedBy = null; aPartsInfo.EditedDateTime = null; unitOfWork.PartsInfoRepository.Insert(aPartsInfo); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Parts Information Added Successfully!" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "Fill Up all required filled" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult AddRoute(VM_Route route) { if (ModelState.IsValid) { try { tblRoute aRoute = new tblRoute(); aRoute.RouteName = route.RouteName; aRoute.WorkShopId = Int32.Parse(SessionManger.WorkShopOfLoggedInUser(Session).ToString()); aRoute.CreatedBy = SessionManger.LoggedInUser(Session); aRoute.CreatedDateTime = DateTime.Now; aRoute.EditedBy = null; aRoute.EditedDateTime = null; unitOfWork.RouteRepository.Insert(aRoute); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Bus Route Added Successfully." }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "Model is not Valid" }, JsonRequestBehavior.AllowGet)); } }
public JsonResult SaveProductToProductionHouse(int StoreId, List <VM_ProductToStore> productList) { try { foreach (VM_ProductToStore aProduct in productList) { tblProductTransfer aProductTransfer = new tblProductTransfer(); aProductTransfer.StoreId = StoreId; aProductTransfer.TransferDate = DateTime.Now; aProductTransfer.SupplierId = null; aProductTransfer.ProductId = aProduct.ProductId; aProductTransfer.Quantity = aProduct.Quantity; aProductTransfer.Unit = aProduct.Unit; aProductTransfer.UnitPrice = (decimal?)aProduct.UnitPrice; aProductTransfer.isIn = true; aProductTransfer.isOut = false; aProductTransfer.DateTime = DateTime.Now; aProductTransfer.RestaurantId = Int32.Parse(SessionManger.RestaurantOfLoggedInUser(Session).ToString()); aProductTransfer.CreatedBy = SessionManger.LoggedInUser(Session); aProductTransfer.CreatedDateTime = DateTime.Now; aProductTransfer.EditedBy = null; aProductTransfer.EditedDateTime = null; unitOfWork.ProductTransferRepository.Insert(aProductTransfer); // MAY BE, DATA INSERTION IN TABLE tblProductEntryToProductionHouse SHOULD BE IMPLEMENTED HERE. } unitOfWork.Save(); return(Json(new { success = true, successMessage = "Product Added Successfully" })); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Update(VM_Route route) { if (ModelState.IsValid) { try { tblRoute aRoute = unitOfWork.RouteRepository.GetByID(route.RouteId); aRoute.RouteName = route.RouteName; aRoute.EditedBy = SessionManger.LoggedInUser(Session); aRoute.EditedDateTime = DateTime.Now; unitOfWork.RouteRepository.Update(aRoute); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Route Info update successfully." }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "Model is not valid" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Update(VM_Action viewAction) { if (ModelState.IsValid) { try { tblAction aAction = unitOfWork.ActionRepository.GetByID(viewAction.ActionId); aAction.ActionName = viewAction.ActionName; aAction.ActionDisplayName = viewAction.ActionDisplayName; aAction.ActionUrl = viewAction.ActionUrl; aAction.ModuleId = viewAction.ModuleId; aAction.IsInMenu = viewAction.IsInMenu; aAction.IsView = viewAction.IsView; aAction.EditedBy = SessionManger.LoggedInUser(Session); aAction.EditedDateTime = DateTime.Now; unitOfWork.ActionRepository.Update(aAction); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Action Info update successfully." }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "Model is not valid" }, JsonRequestBehavior.AllowGet)); } }
public JsonResult AddAction(VM_Action ViewAction) { if (ModelState.IsValid) { try { tblAction aAction = new tblAction(); aAction.ActionName = ViewAction.ActionName; aAction.ActionDisplayName = ViewAction.ActionDisplayName; aAction.ActionUrl = ViewAction.ActionUrl; aAction.ModuleId = ViewAction.ModuleId; aAction.IsInMenu = ViewAction.IsInMenu; aAction.IsView = ViewAction.IsView; aAction.WorkShopId = Int32.Parse(SessionManger.WorkShopOfLoggedInUser(Session).ToString()); aAction.CreatedBy = SessionManger.LoggedInUser(Session); aAction.CreatedDateTime = DateTime.Now; aAction.EditedBy = null; aAction.EditedDateTime = null; unitOfWork.ActionRepository.Insert(aAction); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Action Added Successfully!" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "Fill Up all required filled" }, JsonRequestBehavior.AllowGet)); } }
public JsonResult SaveSellsPoint(VM_SellsPoint aSellsPoint) { if (ModelState.IsValid) { try { tblSellsPoint sellsPoint = new tblSellsPoint(); sellsPoint.SellsPointName = aSellsPoint.SellsPointName; sellsPoint.SellsPointStoreId = aSellsPoint.SellsPointStoreId; sellsPoint.RestaurantId = Int32.Parse(SessionManger.RestaurantOfLoggedInUser(Session).ToString()); sellsPoint.CreatedBy = SessionManger.LoggedInUser(Session); sellsPoint.CreatedDateTime = DateTime.Now; sellsPoint.EditedBy = null; sellsPoint.EditedDateTime = null; unitOfWork.SellsPointRepository.Insert(sellsPoint); unitOfWork.Save(); tblStoreInformation aStoreInformation = unitOfWork.StoreRepository.GetByID(sellsPoint.SellsPointStoreId); aStoreInformation.SellsPointStoreId = sellsPoint.SellsPointId; unitOfWork.StoreRepository.Update(aStoreInformation); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Sells point added successfully" })); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "Model is not Valid" }, JsonRequestBehavior.AllowGet)); } }
public JsonResult UpdateSellsPoint(VM_SellsPoint aSellsPoint) { tblSellsPoint sellsPoint = unitOfWork.SellsPointRepository.GetByID(aSellsPoint.SellsPointId); sellsPoint.SellsPointId = aSellsPoint.SellsPointId; sellsPoint.SellsPointName = aSellsPoint.SellsPointName; sellsPoint.SellsPointStoreId = aSellsPoint.SellsPointStoreId; sellsPoint.EditedBy = SessionManger.LoggedInUser(Session); sellsPoint.EditedDateTime = DateTime.Now; try { //Update previous StoreInformation SellsPointStoreId tblStoreInformation bStoreInformation = unitOfWork.StoreRepository.Get().Where(a => a.SellsPointStoreId == sellsPoint.SellsPointId).FirstOrDefault(); bStoreInformation.SellsPointStoreId = null; unitOfWork.StoreRepository.Update(bStoreInformation); //Update Present StoreInformation SellsPointStoreId tblStoreInformation aStoreInformation = unitOfWork.StoreRepository.GetByID(sellsPoint.SellsPointStoreId); aStoreInformation.SellsPointStoreId = sellsPoint.SellsPointId; unitOfWork.StoreRepository.Update(aStoreInformation); //Update SellsPointRepository unitOfWork.SellsPointRepository.Update(sellsPoint); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Sells Point Edited Successfully" }, JsonRequestBehavior.AllowGet)); } catch (Exception exception) { return(Json(new { success = false, errorMessage = exception.Message }, JsonRequestBehavior.AllowGet)); } }
public ActionResult AddStore(VM_Store store) { if (ModelState.IsValid) { try { tblStore aStore = new tblStore(); aStore.StoreName = store.StoreName; aStore.WorkShopId = Int32.Parse(SessionManger.WorkShopOfLoggedInUser(Session).ToString()); aStore.CreatedBy = SessionManger.LoggedInUser(Session); aStore.CreatedDateTime = DateTime.Now; aStore.EditedBy = null; aStore.EditedDateTime = null; unitOfWork.StoreRepository.Insert(aStore); unitOfWork.Save(); return(Json(new { success = true, successMessage = "Store Save Successfully" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "Store not Save" }, JsonRequestBehavior.AllowGet)); } }
public JsonResult AddProductToProductionHouse(List <Vm_ProductTransfetToProductionHouse> ProductList) { try { tblStoreInformation mainStore = null; tblProductTransfer productTransfer = null; foreach (var productTransfetToProductionHouse in ProductList) { if (productTransfetToProductionHouse.Quantity != null) { productTransfer = new tblProductTransfer(); productTransfer.DateTime = DateTime.Now; productTransfer.CreatedBy = SessionManger.LoggedInUser(Session); productTransfer.EditedBy = null; productTransfer.RestaurantId = Int32.Parse(SessionManger.RestaurantOfLoggedInUser(Session).ToString()); productTransfer.CreatedDateTime = DateTime.Now; productTransfer.StoreId = productTransfetToProductionHouse.StoreId; productTransfer.SupplierId = null; productTransfer.ProductId = productTransfetToProductionHouse.ProductId; productTransfer.Quantity = productTransfetToProductionHouse.Quantity; productTransfer.TransferDate = DateTime.Now; productTransfer.isIn = true; productTransfer.Unit = productTransfetToProductionHouse.Unit; unitOfWork.ProductTransferRepository.Insert(productTransfer); unitOfWork.Save(); //--------- Get Main Store of --> Own Store--------------- mainStore = unitOfWork.StoreRepository.GetByID(productTransfer.StoreId); //----------------- Out Product to Main Store ------------ tblProductTransfer productTransfer2 = new tblProductTransfer(); productTransfer2.StoreId = mainStore.ParentStoreId; productTransfer2.SupplierId = null; productTransfer2.ProductId = productTransfetToProductionHouse.ProductId; productTransfer2.Quantity = productTransfetToProductionHouse.Quantity; productTransfer2.TransferDate = DateTime.Now; productTransfer2.Unit = productTransfetToProductionHouse.Unit; productTransfer2.isOut = true; productTransfer2.CreatedDateTime = DateTime.Now; unitOfWork.ProductTransferRepository.Insert(productTransfer2); productTransfer2.DateTime = DateTime.Now; productTransfer2.CreatedBy = SessionManger.LoggedInUser(Session); productTransfer2.EditedBy = null; productTransfer2.RestaurantId = Int32.Parse(SessionManger.RestaurantOfLoggedInUser(Session).ToString()); unitOfWork.Save(); } } ProductToProductionHouseReport(Convert.ToInt32(mainStore.ParentStoreId), Convert.ToInt32(productTransfer.StoreId), ProductList); //----------- In a Product to Own Store------------------ return(Json(new { success = true, successMessage = "Product Transfer to Product House Successfully" })); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public ActionResult ViewPdfReportForPurchasableProduct(int storeId) { try { string storeName = unitOfWork.StoreRepository.GetByID(storeId).store_name; int restaurantId = Int32.Parse(SessionManger.RestaurantOfLoggedInUser(Session).ToString());; string restaurantName = unitOfWork.RestaurantRepository.GetByID(restaurantId).Name; string restaurantAddress = unitOfWork.RestaurantRepository.GetByID(restaurantId).Address; LocalReport localReport = new LocalReport(); localReport.ReportPath = Server.MapPath("~/Reports/ProductionHouseStatusReport.rdlc"); // localReport.SetParameters(new ReportParameter("StoreName", StoreName)); var a = unitOfWork.CustomRepository.sp_PuschaseableProductStatusInProductionHouse(storeId); localReport.SetParameters(new ReportParameter("RestaurantName", restaurantName)); localReport.SetParameters(new ReportParameter("RestaurantAddress", restaurantAddress)); localReport.SetParameters(new ReportParameter("StoreName", storeName)); ReportDataSource reportDataSource = new ReportDataSource("ProductionHouseSellableProductStatusDataSet", a); localReport.DataSources.Add(reportDataSource); string reportType = "pdf"; string mimeType; string encoding; string fileNameExtension; //The DeviceInfo settings should be changed based on the reportType //http://msdn.microsoft.com/en-us/library/ms155397.aspx string deviceInfo = "<DeviceInfo>" + " <OutputFormat>PDF</OutputFormat>" + " <PageWidth>8.5in</PageWidth>" + " <PageHeight>11in</PageHeight>" + " <MarginTop>0.5in</MarginTop>" + " <MarginLeft>0in</MarginLeft>" + " <MarginRight>0in</MarginRight>" + " <MarginBottom>0.5in</MarginBottom>" + "</DeviceInfo>"; Warning[] warnings; string[] streams; byte[] renderedBytes; //Render the report renderedBytes = localReport.Render( reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings); return(File(renderedBytes, mimeType)); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public async Task <ActionResult> Login(LoginViewModel model, string returnUrl) { TempData["errorMessage"] = string.Empty; if (ModelState.IsValid) { var user = await UserManager.FindAsync(model.UserName, model.Password); if (user != null) { await SignInAsync(user, model.RememberMe); using (HanifWorkShop_DBEntity rc = new HanifWorkShop_DBEntity()) { try { tblWorkShopUser WorkShopUser = new tblWorkShopUser(); var workShop = unitOfWork.WorkShopInformationRepository.Get().Where(x => x.short_name == model.AgencyName).FirstOrDefault(); WorkShopUser.UserId = user.Id; WorkShopUser.is_loggedIn = 1; WorkShopUser.last_logged_time = DateTime.Now; WorkShopUser.workShop_id = workShop.workShop_id; unitOfWork.WorkShopUserRepository.Update(WorkShopUser); unitOfWork.Save(); SessionManger.SetLoggedInTime(Session, DateTime.Now); SessionManger.SetLoggedInUser(Session, model.UserName, workShop.workShop_id); return(Redirect("/#Index")); // return Json(new { success = true, successMessage = "Successfully User Created" }); } catch (Exception) { return(Redirect("/#Login")); throw; } } //return RedirectToLocal(returnUrl); } else { ModelState.AddModelError("", "Invalid username or password."); TempData["errorMessage"] = "Invalid username or password."; //return View(model); View(model); //System.Threading.Thread.SpinWait(60); return(Redirect("/#Login")); } } // If we got this far, something failed, redisplay form //return View(model); TempData["errorMessage"] = "Invalid username or password."; //return View(model); View(model); //System.Threading.Thread.SpinWait(60); return(Redirect("/#Login")); }
public JsonResult SaveUserPermission(decimal[] id, string userId) { //userActionMappingFactory = new UserActionMappingFactory(); //actionFactory = new ActionFactory(); try { List <tblAction> actions = new List <tblAction>(); actions = unitOfWork.ActionRepository.Get().ToList(); List <tblUserActionMapping> actionMappings = new List <tblUserActionMapping>(); actionMappings = unitOfWork.UserActonMappingRepository.Get().Where(a => a.user_id == userId).ToList(); foreach (var items in actionMappings) { unitOfWork.UserActonMappingRepository.Delete(items); } if (id != null) { foreach (var items in id) { tblUserActionMapping actionMapping = new tblUserActionMapping(); actionMapping.action_id = Int32.Parse(items.ToString()); actionMapping.user_id = userId; actionMapping.is_permitted = 1; actionMapping.restaurant_id = Int32.Parse(SessionManger.RestaurantOfLoggedInUser(Session).ToString()); unitOfWork.UserActonMappingRepository.Insert(actionMapping); //var selectedAction = actions.Where(a => a.id == items).FirstOrDefault(); //if (selectedAction != null) //{ // var hidenactions = // actions.Where(ha => ha.class_name == selectedAction.class_name && ha.id != items); // foreach (var hidenAction in hidenactions) // { // tblUserActionMapping hactionMapping = new tblUserActionMapping(); // hactionMapping.action_id = hidenAction.id; // hactionMapping.user_id = userId; // hactionMapping.is_permitted = 1; // hactionMapping.membership_id = SessionManger.BrokerOfLoggedInUser(Session).membership_id; // userActionMappingFactory.Add(hactionMapping); // } //} } } unitOfWork.Save(); return(Json(new { success = true, errorMessage = "Mapped Successfully" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex.Message }, JsonRequestBehavior.AllowGet)); } }
private void UpdateVoucher(acc_VoucherEntry voucherEntry, IEnumerable <VM_AccVoucher> voucherDetails) { using (TransactionScope scope = new TransactionScope()) { acc_VoucherEntry aVoucherEntry = unitOfWork.AccVoucherEntryRepository.GetByID(voucherEntry.VoucherID); aVoucherEntry.Narration = voucherEntry.Narration; aVoucherEntry.EditedBy = SessionManger.LoggedInUser(Session); aVoucherEntry.EditedDateTime = DateTime.Now; unitOfWork.Save(); var vd = unitOfWork.AccVoucherDetailsRepository.Get().Where(a => a.VoucherID == voucherEntry.VoucherID); foreach (var detail in vd) { unitOfWork.AccVoucherDetailsRepository.Delete(detail.VoucherDetailID); } foreach (VM_AccVoucher voucherDetail in voucherDetails) { acc_VoucherDetail accVoucherDetail = new acc_VoucherDetail(); accVoucherDetail.VoucherDetailID = Guid.NewGuid(); accVoucherDetail.VoucherID = aVoucherEntry.VoucherID; accVoucherDetail.LedgerID = Guid.Parse(voucherDetail.LedgerID); accVoucherDetail.Debit = (decimal?)voucherDetail.Debit; accVoucherDetail.Credit = (decimal?)voucherDetail.Credit; accVoucherDetail.ChequeNumber = voucherDetail.ChequeNumber; accVoucherDetail.TransactionDate = aVoucherEntry.TransactionDate; accVoucherDetail.VTypeID = aVoucherEntry.VTypeID; accVoucherDetail.OCode = 1; if (voucherDetail.CreatedBy == "" || voucherDetail.CreatedBy == null) { accVoucherDetail.RestaurantId = Int32.Parse(SessionManger.RestaurantOfLoggedInUser(Session).ToString()); accVoucherDetail.CreatedBy = SessionManger.LoggedInUser(Session); accVoucherDetail.CreatedDateTime = DateTime.Now; } else { accVoucherDetail.RestaurantId = aVoucherEntry.RestaurantId; accVoucherDetail.CreatedBy = aVoucherEntry.CreatedBy; accVoucherDetail.CreatedDateTime = Convert.ToDateTime(aVoucherEntry.CreatedDateTime); } accVoucherDetail.EditedBy = SessionManger.LoggedInUser(Session); accVoucherDetail.EditedDateTime = DateTime.Now; unitOfWork.AccVoucherDetailsRepository.Insert(accVoucherDetail); unitOfWork.Save(); } scope.Complete(); } }
public JsonResult UpdateUser(VM_AspNetUser aUser) { AspNetUser aspNetUser = unitOfWork.AspNetUserRepository.GetByID(aUser.Id); aspNetUser.Id = aUser.Id; aspNetUser.UserFullName = aUser.UserFullName; aspNetUser.UserName = aUser.UserName; aspNetUser.PhoneNumber = aUser.PhoneNo; aspNetUser.Email = aUser.Email; tblWorkShopUser aAgencyUser = unitOfWork.WorkShopUserRepository.Get(a => a.UserId == aUser.Id).FirstOrDefault(); aAgencyUser.EditedBy = SessionManger.LoggedInUser(Session); aAgencyUser.EditedDateTime = DateTime.Now; //PASSOWRD save+ UserName & Email uniQ check required var EmailExist = unitOfWork.AspNetUserRepository.Get() .Where(x => x.Email == aUser.Email && x.Id != aUser.Id).ToList(); var UserNameExist = unitOfWork.AspNetUserRepository.Get() .Where(x => x.UserName == aUser.UserName && x.Id != aUser.Id).ToList(); try { if (!EmailExist.Any()) { if (!UserNameExist.Any()) { //UPDATE unitOfWork.WorkShopUserRepository.Update(aAgencyUser); unitOfWork.AspNetUserRepository.Update(aspNetUser); unitOfWork.Save(); return(Json(new { success = true, successMessage = "User has updated Successfully." }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, errorMessage = "This user name already exist." }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, errorMessage = "This email already exist." }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new { success = false, errorMessage = ex }, JsonRequestBehavior.AllowGet)); } }