public ActionResult Create() { UserCrudServices service = new UserCrudServices(); string name = (string)Session["name"]; List <TransactionAccount> allacc = serviceAccounts.allTransactionaccounts(); if (name == "Admin") { return(View(allacc)); } else { string username = (string)(Session["username"]); User user = service.findByString(username); if (user.option_create == "Y") { return(View(allacc)); } } return(RedirectToAction("Index", "Home")); }
public ActionResult Index(int id) { User user = new User(); UserCrudServices service = new UserCrudServices(); user = service.find(id); List <PinAccounts> listOfPinAccounts = new List <PinAccounts>(); List <Pin_Accounts> list = db.Pin_Accounts.Where(x => x.User_id == id && x.User_type == "User" & x.is_active == 1).ToList(); foreach (var account in list) { PinAccounts pin = new PinAccounts(); pin.Name = account.Account_name; pin.id = account.Account_id; TransactionAccount transAccount = db.TransactionAccounts.Find(account.Account_id); pin.Balance = (int)transAccount.balance; pin.Updated_Time = transAccount.updated_at_.ToShortDateString(); listOfPinAccounts.Add(pin); } int count = listOfPinAccounts.Count; ViewBag.pinAccounts = listOfPinAccounts; return(View(user)); }
public ActionResult Edit(int id) { UserCrudServices service = new UserCrudServices(); List <TransactionAccount> allacc = serviceAccounts.allTransactionaccounts(); ViewBag.AllAccounts = allacc; string name = (string)Session["name"]; if (name == "Admin") { User user = service.find(id); List <Permission> listPermisons = service.findPermissions(id); ViewBag.Permissions = listPermisons; return(View(user)); } string username = (string)(Session["username"]); User users = service.findByString(username); if (users.option_edit == "Y") { User user = service.find(id); List <Permission> listPermisons = service.findPermissions(id); ViewBag.Permissions = listPermisons; return(View(user)); } return(RedirectToAction("Index", "Home")); }
public ActionResult Active(int id) { UserCrudServices service = new UserCrudServices(); User user = service.find(id); user.is_active = "Y"; user.updated_at = DateTime.UtcNow; service.save(); return(RedirectToAction("viewUsers")); }
public ActionResult viewUsers() { string sesion = (string)(Session["name"]); UserCrudServices service = new UserCrudServices(); if (sesion == "Admin") { if (service.allUsers() != null) { List <UserBO> usersbo = service.allUsers(); return(View(usersbo)); } } return(RedirectToAction("userRistrictedView")); }
public ActionResult userRistrictedView() { Database1Entities1 db = new Database1Entities1(); UserCrudServices service = new UserCrudServices(); string username = (string)(Session["username"]); User user = service.findByString(username); RestrictUser rUser = new RestrictUser(); rUser.allusers = service.findAllUsers(); rUser.edit = user.option_edit; rUser.delete = user.option_delete; return(View(rUser)); }
public ActionResult Delete(int id) { UserCrudServices service = new UserCrudServices(); string name = (string)Session["name"]; if (name == "Admin") { User user = service.find(id); user.is_active = "N"; user.updated_at = DateTime.UtcNow; service.save(); return(RedirectToAction("viewUsers")); } else { try { string username = (string)(Session["username"]); User users = service.findByString(username); if (users.option_delete == "Y") { User user = service.find(id); user.is_active = "N"; user.updated_at = DateTime.UtcNow; service.save(); return(RedirectToAction("viewUsers")); } return(RedirectToAction("Index", "Home")); } catch { return(View()); } } }
public ActionResult createPost(HttpPostedFileBase image, string name, string username, string password, string view, string create, string delete, string edit, string accView, string accCreate, string accUpdate, string accDelete, FormCollection collection) { UserCrudServices services = new UserCrudServices(); string names = (string)Session["name"]; string usernames = (string)Session["username"]; if (services.checkUsername(username) == false && image != null && image.ContentLength > 0) { User user = new User(); if (services.Create(collection, image, user)) { foreach (var accName in serviceAccounts.allTransactionaccounts()) { if (Request.Form[accName.name] != null) { string value = Request.Form[accName.name]; Permission p = new Permission(); p.user_id = user.Id; p.account_Name = accName.name; p.urls = "N/A"; services.addPermission(p); } } services.save(); return(RedirectToAction("viewUsers")); } } return(RedirectToAction("Create")); }
public ActionResult editPost(int id, FormCollection collection, HttpPostedFileBase image) { try { UserCrudServices service = new UserCrudServices(); User user = new User(); user = service.find(id); user.name = collection["name"]; user.username = collection["username"]; user.password = collection["password"]; user.email = collection["email"]; user.city = collection["city"]; user.location = collection["address"]; user.cnic = collection["cnic"]; user.phone = collection["phone"]; user.amount_limit = Convert.ToInt32(collection["amountlimit"]); user.updated_at = DateTime.UtcNow; if (image != null && image.ContentLength > 0) { user.image = new byte[image.ContentLength]; image.InputStream.Read(user.image, 0, image.ContentLength); } // Users Permission if (collection["view"] != null) { user.option_view = "Y"; } else { user.option_view = "N"; } if (collection["create"] != null) { user.option_create = "Y"; } else { user.option_create = "N"; } if (collection["delete"] != null) { user.option_delete = "Y"; } else { user.option_delete = "N"; } if (collection["edit"] != null) { user.option_edit = "Y"; } else { user.option_edit = "N"; } // Accounts Permission if (collection["accView"] != null) { user.account_view = "Y"; } else { user.account_view = "N"; } if (collection["accCreate"] != null) { user.account_create = "Y"; } else { user.account_create = "N"; } if (collection["accDelete"] != null) { user.account_delete = "Y"; } else { user.account_delete = "N"; } if (collection["accUpdate"] != null) { user.account_update = "Y"; } else { user.account_update = "N"; } // Employee Permission if (collection["empView"] != null) { user.emplyee_view = 1; } else { user.emplyee_view = 0; } if (collection["empCreate"] != null) { user.employee_add = 1; } else { user.employee_add = 0; } if (collection["empDelete"] != null) { user.employee_delete = 1; } else { user.employee_delete = 0; } if (collection["empUpdate"] != null) { user.employee_edit = 1; } else { user.employee_edit = 0; } // Reports Permission if (collection["viewAll"] != null) { user.all_reports = 1; } else { user.all_reports = 0; } if (collection["viewSale"] != null) { user.sale_reports = 1; } else { user.sale_reports = 0; } if (collection["viewExpense"] != null) { user.expense_reports = 1; } else { user.expense_reports = 0; } if (collection["trialBalance"] != null) { user.trial_balance = 1; } else { user.trial_balance = 0; } if (collection["viewPurchase"] != null) { user.purchase_reports = 1; } else { user.purchase_reports = 0; } if (collection["editPurchase"] != null) { user.purchase_reports_edit = 1; } else { user.purchase_reports_edit = 0; } if (collection["editAll"] != null) { user.all_reports_edit = 1; } else { user.all_reports_edit = 0; } if (collection["editSale"] != null) { user.sale_reports_edit = 1; } else { user.sale_reports_edit = 0; } if (collection["editExpense"] != null) { user.expense_reports_edit = 1; } else { user.expense_reports_edit = 0; } if (collection["viewBankPayment"] != null) { user.bankPaymentReports = 1; } else { user.bankPaymentReports = 0; } // productionReports if (collection["productionReports"] != null) { user.addProduction = 1; } else { user.addProduction = 0; } // Vouchers Permission if (collection["jv"] != null) { user.JV = 1; } else { user.JV = 0; } if (collection["br"] != null) { user.BR = 1; } else { user.BR = 0; } if (collection["bp"] != null) { user.BP = 1; } else { user.BP = 0; } if (collection["cr"] != null) { user.CR = 1; } else { user.CR = 0; } if (collection["cp"] != null) { user.CP = 1; } else { user.CP = 0; } if (collection["sv"] != null) { user.SV = 1; } else { user.SV = 0; } if (collection["pv"] != null) { user.PV = 1; } else { user.PV = 0; } if (collection["upsv"] != null) { user.UPSV = 1; } else { user.UPSV = 0; } if (collection["uppv"] != null) { user.UPPV = 1; } else { user.UPPV = 0; } if (collection["ev"] != null) { user.EV = 1; } else { user.EV = 0; } // SuperVision if (collection["supervision"] != null) { user.supervision = 1; } else { user.supervision = 0; } if (collection["homeScreen"] != null) { user.homeScreen = 1; } else { user.homeScreen = 0; } // Goods Management Permission if (collection["viewGoods"] != null) { user.view_goods = 1; } else { user.view_goods = 0; } if (collection["addGood"] != null) { user.add_goods = 1; } else { user.add_goods = 0; } if (collection["editGood"] != null) { user.edit_goods = 1; } else { user.edit_goods = 0; } if (collection["deleteGood"] != null) { user.delete_goods = 1; } else { user.delete_goods = 0; } if (collection["addType"] != null) { user.add_goodTypes = 1; } else { user.add_goodTypes = 0; } if (collection["editType"] != null) { user.edit_goodTypes = 1; } else { user.edit_goodTypes = 0; } if (collection["deleteType"] != null) { user.delete_goodTypes = 1; } else { user.delete_goodTypes = 0; } if (collection["viewType"] != null) { user.view_goodTypes = 1; } else { user.view_goodTypes = 0; } if (collection["unitRate"] != null) { user.add_unitRate = 1; } else { user.add_unitRate = 0; } // Attendence Permission if (collection["atdView"] != null) { user.view_attendence = 1; } else { user.view_attendence = 0; } if (collection["atdAdd"] != null) { user.add_attedence = 1; } else { user.add_attedence = 0; } if (collection["atdEdit"] != null) { user.edit_attendence = 1; } else { user.edit_attendence = 0; } if (collection["atdReports"] != null) { user.attendence_reports = 1; } else { user.attendence_reports = 0; } // Production Permission if (collection["productionReports"] != null) { user.addProduction = 1; } else { user.addProduction = 0; } if (collection["productionProtien"] != null) { user.production_fat = 1; } else { user.production_fat = 0; } if (collection["productionCarbon"] != null) { user.production_carbon = 1; } else { user.production_carbon = 0; } if (collection["productionBleachOil"] != null) { user.production_bleach = 1; } else { user.production_bleach = 0; } // New Permission if (collection["mainReports"] != null) { user.Main_Reports = 1; } else { user.Main_Reports = 0; } if (collection["multiVouchers"] != null) { user.Multi_Vouchers = 1; } else { user.Multi_Vouchers = 0; } if (collection["unitRates"] != null) { user.Unit_Rate = 1; } else { user.Unit_Rate = 0; } if (collection["stockReports"] != null) { user.Stock_Reports = 1; } else { user.Stock_Reports = 0; } if (collection["stockSummary"] != null) { user.Stock_summary = 1; } else { user.Stock_summary = 0; } if (collection["orders"] != null) { user.S_P_Orders = 1; } else { user.S_P_Orders = 0; } if (collection["pending"] != null) { user.S_P_PendingOrders = 1; } else { user.S_P_PendingOrders = 0; } if (collection["pin"] != null) { user.account_pin = 1; } else { user.account_pin = 0; } if (collection["wev"] != null) { user.WEV = 1; } else { user.WEV = 0; } Database1Entities1 db = new Database1Entities1(); UserCrudServices services = new UserCrudServices(); services.inActivePermissions(user.Id); foreach (var accName in serviceAccounts.allTransactionaccounts()) { if (Request.Form[accName.name] != null) { string value = Request.Form[accName.name]; Permission permit = new Permission(); permit.user_id = user.Id; permit.account_Name = accName.name; permit.urls = "N/A"; permit.is_active = 1; db.Permissions.Add(permit); db.SaveChanges(); } } service.save(); return(RedirectToAction("viewUsers")); } catch { return(View()); } }