public async Task<ActionResult> Delete(string id) { MyRole role = await RoleManager.FindByIdAsync(id); if (role != null) { if (role.Name == "Administrator") { return View("Error", new string[] { "请勿删除该管理员角色!" }); } IdentityResult result = await RoleManager.DeleteAsync(role); if (result.Succeeded) { return RedirectToAction("Index"); } else { return View("Error", result.Errors); } } else { return View("Error", new string[] { "无法找到该Role" }); } }
public async Task <ActionResult> Delete(string Id) { MyRole role = await RoleManager.FindByIdAsync(Id); if (role != null) { IdentityResult result = await RoleManager.DeleteAsync(role); } return(RedirectToAction("Index", "RoleManager")); }
public async Task <JsonResult> CreateRole(MyRole NewRole) { if (!await _roleManager.RoleExistsAsync(NewRole.Name)) { await _roleManager.CreateAsync(new MyRole(NewRole.Name, NewRole.Description)); return(Json("RoleCreated")); } return(Json("RoleExists")); }
public async Task <ActionResult> Edit([Bind(Include = "Id,Name")] MyRole myRole) { if (ModelState.IsValid) { db.Entry(myRole).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index", new { Message = RoleMessageId.ChangeRole })); } return(View(myRole)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Name")] MyRole myRole) { if (ModelState.IsValid) { db.Roles.Add(myRole); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(RedirectToAction("Index", new { Message = RoleMessageId.AddRole })); }
public async Task <ActionResult> Edit(string id) { MyRole role = await RoleManager.FindByIdAsync(id); if (role != null) { return(View(new EditRoleModel { Id = role.Id, Name = role.Name })); } return(RedirectToAction("Index")); }
void 发起者_查看_Click(object sender, HtmlElementEventArgs e) { HtmlElement btn = sender as HtmlElement; int id = Convert.ToInt32(btn.GetAttribute("_id")); MyRole role = (MyRole)Convert.ToInt32(btn.GetAttribute("_MyRole")); BugView frm = new BugView(id, role); frm.WindowState = WindowState.Maximized; if (frm.ShowDialog() == true) { web.Document.InvokeScript("bind"); } }
/// <summary> /// 编辑操作,获取所有隶属于此Role的成员和非隶属于此Role的成员 /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task<ActionResult> Edit(string id) { MyRole role = await RoleManager.FindByIdAsync(id); string[] memberIDs = role.Users.Select(x => x.UserId).ToArray(); IEnumerable<MyUser> members = UserManager.Users.Where(x => memberIDs.Any(y => y == x.Id)); IEnumerable<MyUser> nonMembers = UserManager.Users.Except(members); return View(new RoleEditModel() { Role = role, Members = members, NonMembers = nonMembers }); }
// GET: ControlPanel/Roles/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } MyRole myRole = db.Roles.Find(id); if (myRole == null) { return(HttpNotFound()); } return(View(myRole)); }
public ActionResult DeleteConfirmed(int id) { var role = db.Roles.Find(id); if (role.Users.Count > 0) { return(RedirectToAction("Index", new { Message = RoleMessageId.AssignedRole })); } MyRole myRole = db.Roles.Find(id); db.Roles.Remove(myRole); db.SaveChanges(); return(RedirectToAction("Index", new { Message = RoleMessageId.RemoveRole })); }
protected override void Seed(ExtJS_Store.DAL.ApplicationContext context) { var userManager = new MyUserManager(new UserStore <User>(context)); var roleManager = new MyRoleManager(new RoleStore <MyRole>(context)); // создаем две роли var role1 = new MyRole { Name = "admin" }; var role2 = new MyRole { Name = "user" }; // добавляем роли в бд roleManager.Create(role1); roleManager.Create(role2); // создаем пользователей var user = new User { Email = "*****@*****.**", UserName = "******" }; string password = "******"; var result = userManager.Create(user, password); // если создание пользователя прошло успешно if (result.Succeeded) { // добавляем для пользователя роли userManager.AddToRole(user.Id, role1.Name); userManager.AddToRole(user.Id, role2.Name); } // This method will be called after migrating to the latest version. // You can use the DbSet<T>.AddOrUpdate() helper extension method // to avoid creating duplicate seed data. E.g. // // context.People.AddOrUpdate( // p => p.FullName, // new Person { FullName = "Andrew Peters" }, // new Person { FullName = "Brice Lambson" }, // new Person { FullName = "Rowan Miller" } // ); // }
protected override void Seed(IdentityDbContext context) { MyUserManager userManager = new MyUserManager(new UserStore <MyUser>(context)); MyRoleManager roleManager = new MyRoleManager(new RoleStore <MyRole>(context)); var role1 = new MyRole { Name = "admin" }; var role2 = new MyRole { Name = "user" }; var admin = new MyUser { Email = "*****@*****.**", UserName = "******", Year = 1990 }; string password = "******"; if (userManager.Create(admin, password).Succeeded) { userManager.AddToRole(admin.Id, role1.Name); userManager.AddToRole(admin.Id, role2.Name); } var user = new MyUser { Email = "*****@*****.**", UserName = "******", Year = 1980 }; password = "******"; if (userManager.Create(user, password).Succeeded) { userManager.AddToRole(user.Id, role2.Name); } user = new MyUser { Email = "*****@*****.**", UserName = "******", Year = 1950 }; password = "******"; if (userManager.Create(user, password).Succeeded) { userManager.AddToRole(user.Id, role2.Name); } base.Seed(context); }
public RedirectToRouteResult CreateRole(string id) { if (_rolesService.Enabled) _rolesService.Create(id); MyRole role = new MyRole(); role.RoleName = id; role.Student = ""; role.Subject = ""; role.ClassSubject = ""; role.Level = ""; role.Exam = ""; role.Staff = ""; role.Store = ""; role.StudentFees = ""; role.OnlineExam = ""; role.SecondarySchoolStudent = ""; work.MyRoleRepository.Insert(role); work.Save(); return RedirectToAction("Index"); }
public BugView(int bugid, MyRole myrole) { this.BugID = bugid; this.MyRole = myrole; InitializeComponent(); btnFinish.Visibility = System.Windows.Visibility.Collapsed; if (myrole == BugCenter.MyRole.Handler) { word.richText.Document.ContentEnd.InsertTextInRun("修改完毕,再试试看"); } else if (myrole == BugCenter.MyRole.Submitor) { btnFinish.Visibility = System.Windows.Visibility.Visible; } else if (myrole == BugCenter.MyRole.Admin) { mainGrid.RowDefinitions[1].Height = new GridLength(0); } this.Loaded += BugView_Loaded; }
private async Task CreateRole() { var roleNames = AppSettings.Configs.GetSection("Role").Get <List <string> >(); IdentityResult roleResult; foreach (var roleName in roleNames) { var roleExist = await _roleManager.RoleExistsAsync(roleName); if (!roleExist) { //create the roles and seed them to the database: MyRole role = new MyRole() { Name = roleName }; role.SetDefaultInsertValue(GetCurrentUser()); roleResult = await _roleManager.CreateAsync(role); } } }
public async Task <ActionResult <BaseViewModel <MyUserRole> > > CreateRole(CreateRoleRequestViewModel request) { IdentityResult roleResult; var roleExist = await _roleManager.RoleExistsAsync(request.Name); if (!roleExist) { //create the roles and seed them to the database: MyRole role = new MyRole() { Name = request.Name }; role.SetDefaultInsertValue(GetCurrentUser()); roleResult = await _roleManager.CreateAsync(role); if (roleResult.Succeeded) { return(Ok()); } else { return(BadRequest(new BaseViewModel <string>() { Code = roleResult.Errors.ElementAtOrDefault(0).Code, Description = roleResult.Errors.ElementAtOrDefault(0).Description, StatusCode = HttpStatusCode.BadRequest })); } } else { return(BadRequest(new BaseViewModel <string>() { Code = "ROLE_EXISTED", Description = "Role is existed.", StatusCode = HttpStatusCode.BadRequest })); } }
public async Task <ActionResult> Edit(EditRoleModel model) { if (ModelState.IsValid) { MyRole role = await RoleManager.FindByIdAsync(model.Id); if (role != null) { role.Name = model.Name; IdentityResult result = await RoleManager.UpdateAsync(role); if (result.Succeeded) { return(RedirectToAction("Index", "RoleManager")); } else { ModelState.AddModelError("", "Something is wrong"); } } } return(View(model)); }
/// <summary> /// 绑定下拉列表框,根据参数编码查询绑定 /// </summary> private void cellCmbBind() { IList <MyRole> roles = new List <MyRole>(); MyRole role1 = new MyRole() { text = "管理员", value = "管理员" }; MyRole role2 = new MyRole() { text = "操作员", value = "操作员" }; roles.Add(role1); roles.Add(role2); _cellCmb.ValueMember = "value"; _cellCmb.DisplayMember = "text"; // string[] roles = { "管理员", "操作员" }; _cellCmb.DataSource = roles; _cellCmb.DropDownStyle = ComboBoxStyle.DropDownList; }
public Task <string> GetNormalizedRoleNameAsync(MyRole role, CancellationToken cancellationToken) { throw new NotImplementedException(); }
public Task <string> GetRoleIdAsync(MyRole role, CancellationToken cancellationToken) { throw new NotImplementedException(); }
public ActionResult Create(MyRole Role) { context.Roles.Add(Role); context.SaveChanges(); return(RedirectToAction("Index")); }
/// <summary> /// Create a New role /// </summary> /// <returns></returns> public ActionResult Create() { var Role = new MyRole(); return(View(Role)); }
public Task <IdentityResult> UpdateAsync(MyRole role, CancellationToken cancellationToken) { throw new NotImplementedException(); }
// // GET: /MyRole/Edit/5 public ActionResult Edit(string roleName) { List <MyRole> theRoles = work.MyRoleRepository.Get(a => a.RoleName.Equals(roleName)).ToList(); MyRole theRole = theRoles[0]; // string StudentRoles = theRole.Student; if (string.IsNullOrEmpty(theRole.Student)) { theRole.Student = ""; } string[] StudentActivities = theRole.Student.Split('-'); if (string.IsNullOrEmpty(theRole.Subject)) { theRole.Subject = ""; } string[] SubjectActivities = theRole.Subject.Split('-'); if (string.IsNullOrEmpty(theRole.AttendanceStaff)) { theRole.AttendanceStaff = ""; } string[] AttendanceStaffActivities = theRole.AttendanceStaff.Split('-'); if (string.IsNullOrEmpty(theRole.OrderItem)) { theRole.OrderItem = ""; } string[] OrderItemActivities = theRole.OrderItem.Split('-'); if (string.IsNullOrEmpty(theRole.ClassSubject)) { theRole.ClassSubject = ""; } string[] ClassSubjectActivities = theRole.ClassSubject.Split('-'); if (string.IsNullOrEmpty(theRole.Exam)) { theRole.Exam = ""; } string[] ExamActivities = theRole.Exam.Split('-'); if (string.IsNullOrEmpty(theRole.Level)) { theRole.Level = ""; } string[] LevelActivities = theRole.Level.Split('-'); if (string.IsNullOrEmpty(theRole.StudentFees)) { theRole.StudentFees = ""; } string[] StudentFeesActivities = theRole.StudentFees.Split('-'); if (string.IsNullOrEmpty(theRole.Store)) { theRole.Store = ""; } string[] StoreActivities = theRole.Store.Split('-'); if (string.IsNullOrEmpty(theRole.Staff)) { theRole.Staff = ""; } string[] StaffActivities = theRole.Staff.Split('-'); if (string.IsNullOrEmpty(theRole.OnlineExam)) { theRole.OnlineExam = ""; } string[] OnlineExamActivities = theRole.OnlineExam.Split('-'); if (string.IsNullOrEmpty(theRole.SecondarySchoolStudent)) { theRole.SecondarySchoolStudent = ""; } string[] SecondarySchoolStudent = theRole.SecondarySchoolStudent.Split('-'); if (string.IsNullOrEmpty(theRole.TimeTable)) { theRole.TimeTable = ""; } string[] TimeTableActivities = theRole.TimeTable.Split('-'); if (string.IsNullOrEmpty(theRole.NewsBoard)) { theRole.NewsBoard = ""; } string[] NewsBoardActivities = theRole.NewsBoard.Split('-'); if (string.IsNullOrEmpty(theRole.Parent)) { theRole.Parent = ""; } string[] ParentActivities = theRole.Parent.Split('-'); if (string.IsNullOrEmpty(theRole.BulkSMS)) { theRole.BulkSMS = ""; } string[] BulkSMSActivities = theRole.BulkSMS.Split('-'); if (string.IsNullOrEmpty(theRole.Post)) { theRole.Post = ""; } string[] PostActivities = theRole.Post.Split('-'); if (string.IsNullOrEmpty(theRole.Attendance)) { theRole.Attendance = ""; } string[] AttendanceActivities = theRole.Attendance.Split('-'); if (string.IsNullOrEmpty(theRole.SchoolFeePayment)) { theRole.SchoolFeePayment = ""; } string[] SchoolFeePaymentActivities = theRole.SchoolFeePayment.Split('-'); if (string.IsNullOrEmpty(theRole.StudentStoreItem)) { theRole.StudentStoreItem = ""; } string[] StudentStoreItemtActivities = theRole.StudentStoreItem.Split('-'); if (string.IsNullOrEmpty(theRole.Material)) { theRole.Material = ""; } string[] MaterialActivities = theRole.Material.Split('-'); // string[] MaterialActivities = theRole.Material.Split('-'); // Material List <string> storeActivities = new List <string>(); List <string> studentFeesActivities = new List <string>(); List <string> levelActivities = new List <string>(); List <string> studentActivites = new List <string>(); List <string> subjectActivites = new List <string>(); List <string> classSubjectActivites = new List <string>(); List <string> examActivites = new List <string>(); List <string> staffActivities = new List <string>(); List <string> onlineexamActivities = new List <string>(); List <string> timeTableActivities = new List <string>(); List <string> newsBoardActivities = new List <string>(); List <string> secondarySchoolStudent = new List <string>(); List <string> parentActivities = new List <string>(); List <string> bulkSMSActivities = new List <string>(); List <string> postActivities = new List <string>(); List <string> attendanceActivities = new List <string>(); List <string> attendanceStaffActivities = new List <string>(); List <string> orderItemActivities = new List <string>(); List <string> schoolFeePaymentActivities = new List <string>(); List <string> studentStoreItemtActivities = new List <string>(); List <string> materialtActivities = new List <string>(); // List<string> newsBoardActivities = new List<string>(); foreach (var role in SecondarySchoolStudent) { secondarySchoolStudent.Add(role); } foreach (var role in AttendanceActivities) { attendanceActivities.Add(role); } foreach (var role in OnlineExamActivities) { onlineexamActivities.Add(role); } foreach (var role in StaffActivities) { staffActivities.Add(role); } foreach (var role in StoreActivities) { storeActivities.Add(role); } foreach (var role in StudentFeesActivities) { studentFeesActivities.Add(role); } foreach (var role in LevelActivities) { levelActivities.Add(role); } foreach (var role in ExamActivities) { examActivites.Add(role); } foreach (var role in ClassSubjectActivities) { classSubjectActivites.Add(role); } foreach (var role in SubjectActivities) { subjectActivites.Add(role); } foreach (var role in StudentActivities) { studentActivites.Add(role); } foreach (var role in TimeTableActivities) { timeTableActivities.Add(role); } foreach (var role in NewsBoardActivities) { newsBoardActivities.Add(role); } foreach (var role in ParentActivities) { parentActivities.Add(role); } foreach (var role in BulkSMSActivities) { bulkSMSActivities.Add(role); } foreach (var role in PostActivities) { postActivities.Add(role); } foreach (var role in AttendanceStaffActivities) { attendanceStaffActivities.Add(role); } foreach (var role in OrderItemActivities) { orderItemActivities.Add(role); } foreach (var role in SchoolFeePaymentActivities) { schoolFeePaymentActivities.Add(role); } foreach (var role in StudentStoreItemtActivities) { studentStoreItemtActivities.Add(role); } foreach (var role in MaterialActivities) { materialtActivities.Add(role); } //StudentStoreItemt //PopulateStudentActivity(theRole, studentActivites, "Student"); PopulateActivity(theRole, staffActivities, "Staff"); PopulateActivity(theRole, storeActivities, "Store"); PopulateActivity(theRole, studentFeesActivities, "StudentFees"); PopulateActivity(theRole, levelActivities, "Level"); PopulateActivity(theRole, examActivites, "Exam"); PopulateActivity(theRole, classSubjectActivites, "ClassSubject"); PopulateActivity(theRole, studentActivites, "Student"); PopulateActivity(theRole, subjectActivites, "Subject"); PopulateActivity(theRole, onlineexamActivities, "OnlineExam"); PopulateActivity(theRole, secondarySchoolStudent, "SecondarySchoolStudent"); PopulateActivity(theRole, timeTableActivities, "TimeTable"); PopulateActivity(theRole, newsBoardActivities, "NewsBoard"); PopulateActivity(theRole, parentActivities, "Parent"); PopulateActivity(theRole, bulkSMSActivities, "BulkSMS"); PopulateActivity(theRole, postActivities, "Post"); PopulateActivity(theRole, attendanceActivities, "Attendance"); PopulateActivity(theRole, attendanceStaffActivities, "AttendanceStaff"); PopulateActivity(theRole, orderItemActivities, "OrderItem"); PopulateActivity(theRole, schoolFeePaymentActivities, "SchoolFeePayment"); PopulateActivity(theRole, studentStoreItemtActivities, "StudentStoreItem"); PopulateActivity(theRole, materialtActivities, "UploadLessonNote"); return(View(theRole)); // return View(); }
public ActionResult Edit(MyRole model, string[] selectedCourses) { try { StringBuilder studentActivites = new StringBuilder(); StringBuilder subjectActivites = new StringBuilder(); StringBuilder storeActivities = new StringBuilder(); StringBuilder studentFeesActivities = new StringBuilder(); StringBuilder levelActivities = new StringBuilder(); StringBuilder classSubjectActivites = new StringBuilder(); StringBuilder examActivites = new StringBuilder(); StringBuilder staffActivities = new StringBuilder(); StringBuilder onlineexamActivities = new StringBuilder(); StringBuilder secondarySchoolStudentActivities = new StringBuilder(); StringBuilder timeTableActivities = new StringBuilder(); StringBuilder newsBoardActivities = new StringBuilder(); StringBuilder parentActivities = new StringBuilder(); StringBuilder bulkSMSActivities = new StringBuilder(); StringBuilder postActivities = new StringBuilder(); StringBuilder attendanceActivities = new StringBuilder(); StringBuilder attendanceStaffActivities = new StringBuilder(); StringBuilder orderItemActivities = new StringBuilder(); StringBuilder schoolFeePaymentActivities = new StringBuilder(); StringBuilder studentStoreItemtActivities = new StringBuilder(); StringBuilder materialActivities = new StringBuilder(); // StringBuilder attendanceActivities = new StringBuilder();StudentStoreItem // strinb studentActivites = ""; if (selectedCourses != null) { foreach (var activities in selectedCourses) { String[] fakeActivity = activities.Split(' '); string theac = fakeActivity[1]; if (activities.EndsWith("OnlineExam") && theac == "OnlineExam") { String[] realActivity = activities.Split(' '); onlineexamActivities.Append(realActivity[0]); onlineexamActivities.Append("-"); } if (activities.EndsWith("Student") && theac == "Student") { String[] realActivity = activities.Split(' '); studentActivites.Append(realActivity[0]); studentActivites.Append("-"); } if (activities.EndsWith("SecondarySchoolStudent") && theac == "SecondarySchoolStudent") { String[] realActivity = activities.Split(' '); secondarySchoolStudentActivities.Append(realActivity[0]); secondarySchoolStudentActivities.Append("-"); } if (activities.EndsWith("Subject") && theac == "Subject") { String[] realActivity = activities.Split(' '); subjectActivites.Append(realActivity[0]); // subjectActivites.Append(activities); subjectActivites.Append("-"); } if (activities.EndsWith("Staff")) { String[] staffActivity = activities.Split(' '); staffActivities.Append(staffActivity[0]); // subjectActivites.Append(activities); staffActivities.Append("-"); } if (activities.EndsWith("Table")) { String[] timeTableActivity = activities.Split(' '); timeTableActivities.Append(timeTableActivity[0]); // subjectActivites.Append(activities); timeTableActivities.Append("-"); } if (activities.EndsWith("Board")) { String[] newsBoardActivity = activities.Split(' '); newsBoardActivities.Append(newsBoardActivity[0]); // subjectActivites.Append(activities); newsBoardActivities.Append("-"); } if (activities.EndsWith("Store")) { String[] storeActivity = activities.Split(' '); storeActivities.Append(storeActivity[0]); // subjectActivites.Append(activities); storeActivities.Append("-"); } if (activities.EndsWith("OrderItem")) { String[] orderItemActivity = activities.Split(' '); orderItemActivities.Append(orderItemActivity[0]); // subjectActivites.Append(activities); orderItemActivities.Append("-"); } if (activities.EndsWith("StudentFees")) { String[] studentFeesActivity = activities.Split(' '); studentFeesActivities.Append(studentFeesActivity[0]); // subjectActivites.Append(activities); studentFeesActivities.Append("-"); } if (activities.EndsWith("Level")) { String[] levelActivity = activities.Split(' '); levelActivities.Append(levelActivity[0]); // subjectActivites.Append(activities); levelActivities.Append("-"); } if (activities.EndsWith("Exam") && theac == "Exam") { String[] examlActivity = activities.Split(' '); examActivites.Append(examlActivity[0]); // subjectActivites.Append(activities); examActivites.Append("-"); } if (activities.EndsWith("ClassSubject")) { String[] classSubjectlActivity = activities.Split(' '); classSubjectActivites.Append(classSubjectlActivity[0]); // subjectActivites.Append(activities); classSubjectActivites.Append("-"); } if (activities.EndsWith("Parent")) { String[] parentActivity = activities.Split(' '); parentActivities.Append(parentActivity[0]); // subjectActivites.Append(activities); parentActivities.Append("-"); } if (activities.EndsWith("SMS")) { String[] bulkSMSActivity = activities.Split(' '); bulkSMSActivities.Append(bulkSMSActivity[0]); // subjectActivites.Append(activities); bulkSMSActivities.Append("-"); } if (activities.EndsWith("Post")) { String[] postActivity = activities.Split(' '); postActivities.Append(postActivity[0]); // subjectActivites.Append(activities); postActivities.Append("-"); } if (activities.EndsWith("Attendance") && theac == "Attendance") { String[] attendanceActivity = activities.Split(' '); attendanceActivities.Append(attendanceActivity[0]); // subjectActivites.Append(activities); attendanceActivities.Append("-"); } if (activities.EndsWith("AttendanceStaff")) { String[] attendanceStaffActivity = activities.Split(' '); attendanceStaffActivities.Append(attendanceStaffActivity[0]); // subjectActivites.Append(activities); attendanceStaffActivities.Append("-"); }// if (activities.EndsWith("SchoolFeePayment")) { String[] schoolFeePaymentActivity = activities.Split(' '); schoolFeePaymentActivities.Append(schoolFeePaymentActivity[0]); // subjectActivites.Append(activities); schoolFeePaymentActivities.Append("-"); }//StudentStoreItem if (activities.EndsWith("StudentStoreItem")) { String[] studentStoreItemActivity = activities.Split(' '); studentStoreItemtActivities.Append(studentStoreItemActivity[0]); studentStoreItemtActivities.Append("-"); } if (activities.EndsWith("UploadLessonNote")) { String[] materialActivity = activities.Split(' '); materialActivities.Append(materialActivity[0]); materialActivities.Append("-"); } } } model.ClassSubject = Convert.ToString(classSubjectActivites); model.Exam = Convert.ToString(examActivites); model.Level = Convert.ToString(levelActivities); model.StudentFees = Convert.ToString(studentFeesActivities); model.Store = Convert.ToString(storeActivities); model.Staff = Convert.ToString(staffActivities); model.Subject = Convert.ToString(subjectActivites); model.Student = Convert.ToString(studentActivites); model.OnlineExam = Convert.ToString(onlineexamActivities); model.SecondarySchoolStudent = Convert.ToString(secondarySchoolStudentActivities); model.TimeTable = Convert.ToString(timeTableActivities); model.NewsBoard = Convert.ToString(newsBoardActivities); model.Parent = Convert.ToString(parentActivities); model.BulkSMS = Convert.ToString(bulkSMSActivities); model.Post = Convert.ToString(postActivities); model.Attendance = Convert.ToString(attendanceActivities); model.AttendanceStaff = Convert.ToString(attendanceStaffActivities); model.OrderItem = Convert.ToString(orderItemActivities); model.SchoolFeePayment = Convert.ToString(schoolFeePaymentActivities); // model.StudentStoreItem = Convert.ToString(studentStoreItemtActivities); //studentStoreItemtActivities model.Material = Convert.ToString(materialActivities); // TODO: Add update logic here work.MyRoleRepository.Update(model); work.Save(); return(RedirectToAction("Index", "UserAdministration")); } catch { return(View()); } }
private void PopulateActivity(MyRole instructo, List <string> roles, string type) { var allActivites = new List <string>() { "List", "Create", "Edit", "Delete", "Details" }; var viewModel = new List <ActivityData>(); foreach (var activity in allActivites) { viewModel.Add(new ActivityData { // ActivityID = course.SubjectID, Name = activity + " " + type, Assigned = roles.Contains(activity) }); } if (type.Equals("Staff")) { ViewBag.Staff = viewModel; } if (type.Equals("Store")) { ViewBag.Store = viewModel; } if (type.Equals("StudentFees")) { ViewBag.StudentFees = viewModel; } if (type.Equals("Level")) { ViewBag.Level = viewModel; } if (type.Equals("Exam")) { ViewBag.Exam = viewModel; } if (type.Equals("ClassSubject")) { ViewBag.ClassSubject = viewModel; } if (type.Equals("Student")) { ViewBag.Student = viewModel; } if (type.Equals("Subject")) { ViewBag.Subject = viewModel; } if (type.Equals("OnlineExam")) { ViewBag.OnlineExam = viewModel; } if (type.Equals("SecondarySchoolStudent")) { ViewBag.SecondarySchoolStudent = viewModel; } if (type.Equals("TimeTable")) { ViewBag.TimeTable = viewModel; } if (type.Equals("NewsBoard")) { ViewBag.NewsBoard = viewModel; } if (type.Equals("Parent")) { ViewBag.Parent = viewModel; } if (type.Equals("BulkSMS")) { ViewBag.BulkSMS = viewModel; } if (type.Equals("Post")) { ViewBag.Post = viewModel; } if (type.Equals("Attendance")) { ViewBag.Attendance = viewModel; } if (type.Equals("AttendanceStaff")) { ViewBag.AttendanceStaff = viewModel; } if (type.Equals("OrderItem")) { ViewBag.OrderItem = viewModel; } if (type.Equals("SchoolFeePayment")) { ViewBag.SchoolFeePayment = viewModel; } if (type.Equals("StudentStoreItem")) { ViewBag.StudentStoreItem = viewModel; } if (type.Equals("UploadLessonNote")) { ViewBag.UploadLessonNote = viewModel; } // ViewBag.Subject = viewModel;studentStoreItemtActivities }
protected override void Seed(ExtStore2.DAL.ApplicationContext context) { var userManager = new MyUserManager(new UserStore <User>(context)); var roleManager = new MyRoleManager(new RoleStore <MyRole>(context)); // создаем две роли var role1 = new MyRole { Name = "admin" }; var role2 = new MyRole { Name = "user" }; // добавляем роли в бд roleManager.Create(role1); roleManager.Create(role2); // создаем пользователей var user = new User { Email = "*****@*****.**", UserName = "******", Name = "Admin", Address = "My address", Code = "My code", Discount = 50 }; string password = "******"; var result = userManager.Create(user, password); // если создание пользователя прошло успешно if (result.Succeeded) { // добавляем для пользователя роли userManager.AddToRole(user.Id, role1.Name); userManager.AddToRole(user.Id, role2.Name); } var products = new List <Product> { new Product { Name = "Продукт 1", Price = 100, Category = "Category", Code = "Code 1" }, new Product { Name = "Продукт 2", Price = 500, Category = "Category", Code = "Code 2" }, new Product { Name = "Новый продукт 3", Price = 8350, Category = "New category", Code = "New code 1" }, new Product { Name = "Новый продукт 4", Price = 15613, Category = "New category", Code = "New code 2" } }; for (int i = 1; i <= 50; i++) { products.Add(new Product { Name = "Product " + i, Price = i * 1000 + i * 3, Category = "Category " + i, Code = "Code " + i }); } ; products.ForEach(s => context.Products.AddOrUpdate(p => p.Name, s)); context.SaveChanges(); }
public Task SetRoleNameAsync(MyRole role, string roleName, CancellationToken cancellationToken) { throw new NotImplementedException(); }