public Response <CompanyDto> UpdateCompanyStatus(BulkUpdateModel bulkUpdateModel) { using (UnitOfWork unitOfWork = new UnitOfWork()) { return(unitOfWork.Companies.UpdateStatus(bulkUpdateModel)); } }
public ActionResult BulkUpdate(BulkUpdateModel model, string submitButton) { //check the other submit buttons and act on them, or continue switch (submitButton) { case "Cancel": return(RedirectToAction("Index", "Users")); } //case "Save": if (ModelState.IsValid) { var changeType = ChangeType.Status; if (Session["__SavedChangeType"] != null) { changeType = Session["__SavedChangeType"] is ChangeType ? (ChangeType)Session["__SavedChangeType"] : ChangeType.Status; //clear the session } try { //get the users to act on var usrMgr = new UserFactory(); //determine the action if (changeType == ChangeType.Status) { //if status, update status for those users bool active = model.Action == "Active"; foreach (var userName in GetActionableUsernames()) { usrMgr.UpdateUserStatus(userName, active); } } else { //if roles, update roles for those users - role is the current action var roleName = model.Action; //clear all first, then update foreach (var userName in GetActionableUsernames()) { //clear all their group permissions CurrentAuthorizationManager.RemoveMemberGroups(userName); // now add them to the specific group for this store they will have access to CurrentAuthorizationManager.AddGroupMember(roleName, userName); } } // send them back to the user listing page. return(RedirectToAction("Index", "Users")); } catch (Exception e) { ModelState.AddModelError("", "Could not update users profile."); } } // If we got this far, something failed, redisplay form model.Groups = GetGroups(); return(View(model)); }
public Response <CompanyDto> UpdateStatus(BulkUpdateModel bulkUpdateModel) { List <SqlQueryParameter> sqlQueryParameters = new List <SqlQueryParameter>(); sqlQueryParameters.Add(new SqlQueryParameter { ParameterName = "EditUserId", ParameterDirection = DbParameterDirection.Input, ParamentType = CodeParameterType.Integer, ParameterValue = bulkUpdateModel.EditUserId }); sqlQueryParameters.Add(new SqlQueryParameter { ParameterName = "StatusCode", ParameterDirection = DbParameterDirection.Input, ParamentType = CodeParameterType.String, ParameterSize = 100, ParameterValue = bulkUpdateModel.StatusCode }); sqlQueryParameters.Add(new SqlQueryParameter { ParameterName = "Companies", ParameterDirection = DbParameterDirection.Input, ParamentType = CodeParameterType.Structured, ParameterValue = bulkUpdateModel.Ids.ValueListToDataTable <int>("Id") }); sqlQueryParameters.Add(new SqlQueryParameter { ParameterName = "ValidationMessages", ParameterDirection = DbParameterDirection.Output, ParamentType = CodeParameterType.String, ParameterSize = 8000 }); return(Save("CompanyStatusUpdate", null, sqlQueryParameters.ToArray())); }
public ActionResult Action(string ddlActionValue) { //get the userIds out of session var model = new BulkUpdateModel { Groups = GetGroups(), ChangeType = ddlActionValue == "ChangeRole" ? ChangeType.Role : ChangeType.Status }; //save the change type Session["__SavedChangeType"] = model.ChangeType; var userNames = GetActionableUsernames(); if (userNames != null) { model.UserNames = userNames; } return(View("BulkUpdate", model)); }
public HttpResponseMessage UpdateCompanyStatus(BulkUpdateModel bulkUpdateModel) { bulkUpdateModel.EditUserId = UserId.Value; return(Request.CreateResponse <Response <CompanyDto> >(HttpStatusCode.OK, companyManager.UpdateCompanyStatus(bulkUpdateModel))); }