public ActionResult Users() { var repo = AdminFactory.GetRepo(); var model = repo.GetAllUsers(); return(View(model)); }
public IHttpActionResult AllCarSearch(decimal?minPrice, decimal?maxPrice, int?minYear, int?maxYear, string searchTerm) { var repo = AdminFactory.GetRepo(); try { var parameters = new InventorySearchParameters() { SearchTerm = searchTerm, MinPrice = minPrice, MaxPrice = maxPrice, MinYear = minYear, MaxYear = maxYear }; var result = repo.AllCarSearch(parameters); if (result.Count == 0) { return(NotFound()); } return(Ok(result)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public ActionResult Makes() { var repo = AdminFactory.GetRepo(); var model = repo.GetCarMakesWUsers(); return(View(model)); }
public ActionResult Makes(CarMake carMake) { if (string.IsNullOrEmpty(carMake.MakeName)) { ModelState.AddModelError("error", "Please enter a new make"); } var repo = AdminFactory.GetRepo(); if (ModelState.IsValid) { try { carMake.User = User.Identity.Name; carMake.MakeName = carMake.MakeName.Substring(0, 1).ToUpper() + carMake.MakeName.Substring(1); repo.AddMake(carMake); } catch (Exception ex) { throw ex; } var model = repo.GetCarMakesWUsers(); return(View("Makes", model)); } else { var model = repo.GetCarMakesWUsers(); return(View(model)); } }
public ActionResult Specials(string title, string description) { var repo = AdminFactory.GetRepo(); if (string.IsNullOrEmpty(title) || string.IsNullOrEmpty(description)) { ModelState.AddModelError("error", "Please enter a new special title & description"); } if (ModelState.IsValid) { Special special = new Special(); special.SpecialTitle = title.First().ToString().ToUpper() + title.Substring(1); special.SpecialDescription = description.First().ToString().ToUpper() + description.Substring(1); repo.AddSpecial(special); var model = repo.GetAllSpecials(); return(View(model)); } else { var model = repo.GetAllSpecials(); return(View(model)); } }
public ISolicitudJuegoHandler getSJHandler() { if (solicitudJHandler == null) { solicitudJHandler = new SolicitudJuegoHandlerEF(AdminFactory.getAdminCtx()); } return(solicitudJHandler); }
public IJuegoHandler getJuegoHandler() { if (juegoHandler == null) { juegoHandler = new JuegoHandlerEF(AdminFactory.getAdminCtx()); } return(juegoHandler); }
public ActionResult DeleteSpecial(int id) { var repo = AdminFactory.GetRepo(); repo.DeleteSpecial(id); var model = repo.GetAllSpecials(); return(View("Specials", model)); }
protected void dgUserList_ItemCommand(object source, DataGridCommandEventArgs e) { if (e.CommandArgument.ToString() == "DeleteInfo") { int dataKey = Convert.ToInt32(this.dgUserList.DataKeys[e.Item.ItemIndex]); AdminFactory.Delete(dataKey); this.LoadListData(); } }
public ActionResult AddUser() { var model = new UserViewModel(); var repo = AdminFactory.GetRepo(); model.User = new User(); model.Roles = new SelectList(repo.GetAllRoles(), "RoleName", "RoleName"); return(View(model)); }
public async Task <HttpResponseMessage> GetUsersData() { AdminFactory _adminFactory = new AdminFactory(); var adminResponse = await _adminFactory.GetUsersData().ConfigureAwait(false); HttpResponseMessage response; response = Request.CreateResponse(HttpStatusCode.OK, adminResponse); return(response); }
public ActionResult Sales() { var model = new SalesReportViewModel(); var repo = AdminFactory.GetRepo(); model.UserList = repo.GetAllUsers(); model.SalesList = new List <Models.Tables.SalesReport>(); return(View(model)); }
public ActionResult EditUser(string id) { var model = new UserViewModel(); var repo = AdminFactory.GetRepo(); model.User = repo.GetUserById(id); model.Roles = new SelectList(repo.GetAllRoles(), "RoleName", "RoleName"); return(View(model)); }
public async Task <HttpResponseMessage> UpdateUserApproveStatus([FromBody] UpdateApproveRequest updateApprove) { AdminFactory _adminFactory = new AdminFactory(); var adminResponse = await _adminFactory.UpdateUserApproveStatus(updateApprove.id, updateApprove.statusId).ConfigureAwait(false); HttpResponseMessage response; response = Request.CreateResponse(HttpStatusCode.OK, adminResponse); return(response); }
public ActionResult Inventory() { var repo = AdminFactory.GetRepository(); InventoryReportVM model = new InventoryReportVM() { NewInventoryReport = repo.GetInventoryReport(1), UsedInventoryReport = repo.GetInventoryReport(2) }; return(View(model)); }
public IHttpActionResult GetRightModels(int id) { var repo = AdminFactory.GetRepo(); try { var carModels = repo.GetCarModelsByMakeId(id); return(Ok(carModels)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public ActionResult Models() { var model = new AddCarModelViewModel(); var repoAdmin = AdminFactory.GetRepo(); var repoVehicle = VehicleFactory.GetRepo(); model.CarMakeList = new List <GetCarMake>(); model.CarMakeList = repoVehicle.GetCarMake(); model.CarModelViewList = new List <CarModelView>(); model.CarModelViewList = repoAdmin.GetCarModelsWUsers().OrderBy(x => x.ModelName); return(View(model)); }
protected void Page_Load(object sender, EventArgs e) { Security.CheckAdministerAndRedirect(); if (!Page.IsPostBack) { if (this.Action == "edit") { int adminid = HYRequest.GetQueryInt("adminid", 0); AdminModel info = AdminFactory.Get(adminid); this.txtusername.Text = info.username; this.txtusername.Enabled = false; } } }
public async Task <ActionResult> Login(LoginViewModel model, string returnUrl) { if (!ModelState.IsValid) { return(View(model)); } var repo = AdminFactory.GetRepo(); var userList = repo.GetAllUsers(); Models.Tables.User user = userList.FirstOrDefault(u => u.Email == model.Email); if (user == null) { ModelState.AddModelError("", "Invalid login attempt."); return(View(model)); } string username = user.FirstName + " " + user.LastName; // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, change to shouldLockout: true var result = await SignInManager.PasswordSignInAsync(username, model.Password, model.RememberMe, shouldLockout : false); if (user.Role == "Disabled") { result = SignInStatus.LockedOut; } switch (result) { case SignInStatus.Success: return(RedirectToLocal(returnUrl)); case SignInStatus.LockedOut: return(View("Lockout")); case SignInStatus.RequiresVerification: return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe })); case SignInStatus.Failure: default: ModelState.AddModelError("", "Invalid login attempt."); return(View(model)); } }
public async Task <ActionResult> EditUser(UserViewModel model) { var repo = AdminFactory.GetRepo(); if (ModelState.IsValid) { try { var editUser = UserManager.FindById(model.User.UserId); editUser.Email = model.User.Email; editUser.UserName = model.User.FirstName.Substring(0, 1).ToUpper() + model.User.FirstName.Substring(1) + " " + model.User.LastName.Substring(0, 1).ToUpper() + model.User.LastName.Substring(1); var roles = await UserManager.GetRolesAsync(editUser.Id); await UserManager.RemoveFromRolesAsync(editUser.Id, roles.ToArray()); var result1 = UserManager.AddToRole(editUser.Id, model.User.Role); var chkUser = await UserManager.UpdateAsync(editUser); if (chkUser.Succeeded && !string.IsNullOrEmpty(model.User.Password)) { ApplicationDbContext context = new ApplicationDbContext(); UserStore <ApplicationUser> store = new UserStore <ApplicationUser>(context); UserManager <ApplicationUser> manager = new UserManager <ApplicationUser>(store); string newPassword = model.User.Password; string hashedNewPassword = UserManager.PasswordHasher.HashPassword(newPassword); ApplicationUser cUser = await store.FindByIdAsync(model.User.UserId); await store.SetPasswordHashAsync(cUser, hashedNewPassword); await store.UpdateAsync(cUser); } if (chkUser.Succeeded) { var result = UserManager.Update(editUser); } } catch (Exception ex) { throw ex; } } return(RedirectToAction("Users")); }
public ActionResult Models(string modelName, int makeid) { if (string.IsNullOrEmpty(modelName) || makeid == 0) { ModelState.AddModelError("error", "Please enter a new model"); } var repo = AdminFactory.GetRepo(); if (ModelState.IsValid) { try { CarModelView newModel = new CarModelView(); newModel.ModelName = modelName.Substring(0, 1).ToUpper() + modelName.Substring(1); newModel.CarMakeId = makeid; newModel.User = User.Identity.Name; repo.AddModel(newModel); } catch (Exception ex) { throw ex; } return(RedirectToAction("Models")); } else { var model = new AddCarModelViewModel(); var repoAdmin = AdminFactory.GetRepo(); var repoVehicle = VehicleFactory.GetRepo(); model.CarMakeList = new List <GetCarMake>(); model.CarMakeList = repoVehicle.GetCarMake(); model.CarModelViewList = new List <CarModelView>(); model.CarModelViewList = repoAdmin.GetCarModelsWUsers(); return(View(model)); } }
public ActionResult Sales() { var repo = AdminFactory.GetRepository(); SalesReportDropDownVM model = new SalesReportDropDownVM(); var users = repo.GetUsers(); foreach (var user in users) { var userName = user.FirstName + " " + user.LastName; user.FullName = userName; } model.UserNames = new SelectList(users, "UserId", "FullName"); return(View(model)); }
public static bool Login(string username, string password, out string tips) { AdminModel info = AdminFactory.Get(username); if (info == null) { tips = "此用户不存在!"; return(false); } if (info.userpwd != Utils.MD5(password)) { tips = "密码不正确!"; return(false); } WriteUserCookie(info, 0); tips = "登陆成功!"; return(true); }
public IHttpActionResult SalesReport(string userId, DateTime?fromDate, DateTime?toDate) { var repo = AdminFactory.GetRepository(); try { var parameters = new SalesReportParameters() { UserId = userId, FromDate = fromDate, ToDate = toDate }; var result = repo.GetSalesReport(parameters); return(Ok(result)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
protected void btnSave_Click(object sender, EventArgs e) { if (this.Action == "edit") { int adminid = HYRequest.GetQueryInt("adminid", 0); AdminModel info = AdminFactory.Get(adminid); if (info != null) { string pwdstr = this.txtpassword.Text.Trim(); if (!string.IsNullOrEmpty(pwdstr)) { info.userpwd = Utils.MD5(pwdstr); } AdminFactory.Update(info); Response.Redirect("adminlist.aspx"); } } else if (this.Action == "add") { //验证是否存在同名的帐号 AdminModel info = null; string username = this.txtusername.Text.Trim(); info = AdminFactory.Get(username); if (info != null) { ClientScript.RegisterStartupScript(this.GetType(), "AddEditTips", "<script language=\"javascript\">alert('已存在相同的帐号!');window.location='adminedit.aspx?action=add';</script>"); return; } info = new AdminModel(); info.username = this.txtusername.Text.Trim(); info.userpwd = Utils.MD5(this.txtpassword.Text.Trim()); AdminFactory.Add(info); Response.Redirect("adminlist.aspx"); } }
public async Task <ActionResult> AddUser(UserViewModel model) { var repo = AdminFactory.GetRepo(); if (ModelState.IsValid) { try { ApplicationUser user = new ApplicationUser(); user.Email = model.User.Email; user.UserName = model.User.FirstName.Substring(0, 1).ToUpper() + model.User.FirstName.Substring(1) + " " + model.User.LastName.Substring(0, 1).ToUpper() + model.User.LastName.Substring(1); var chkUser = await UserManager.CreateAsync(user, model.User.Password); if (chkUser.Succeeded) { var result1 = UserManager.AddToRole(user.Id, model.User.Role); return(RedirectToAction("EditUser", new { id = user.Id })); } else { ModelState.AddModelError("error", "An error occurred. Email may already be taken"); model.Roles = new SelectList(repo.GetAllRoles(), "RoleName", "RoleName"); return(View(model)); } } catch (Exception ex) { throw ex; } } model.User = new User(); model.Roles = new SelectList(repo.GetAllRoles(), "RoleName", "RoleName"); return(View(model)); }
public PartTwelveController() { _adminFactory = new AdminFactory(); }
public PartSevenController() { _adminFactory = new AdminFactory(); }
public RoomsController() { _adminFactory = new AdminFactory(); }
public PartNineController() { _adminFactory = new AdminFactory(); }