public async Task <IActionResult> Create(Users data) { var u = _userService.Create(data); _RolesService.Create(u.Id, data.RolesSelected); return(await Task.FromResult(Ok())); }
public IHttpActionResult Create([FromBody] Role value) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { service.Create(value); return(CreatedAtRoute("Roles_Create", new { id = value.Id }, value)); } catch (UnauthorizedAccessException) { return(StatusCode(HttpStatusCode.Forbidden)); } catch (KeyNotFoundException) { return(NotFound()); } catch (Exception e) { return(InternalServerError(e)); } }
public RedirectToRouteResult CreateRole(string id) { if (_rolesService.Enabled) { _rolesService.Create(id); } return(RedirectToAction("Index")); }
public RedirectToRouteResult CreateRole(string id) { if (!string.IsNullOrWhiteSpace(id)) { _rolesService.Create(id); } return(RedirectToAction("Index")); }
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 ActionResult Create(RolesViewModel model) { var permissions = GetGroupForeignData(); ViewBag.Data_Permissions = permissions; ServiceResult result = new ServiceResult(); TempData["Service_Result"] = result; if (ModelState.IsValid) { try { Roles entity = new Roles(); entity.Name = model.Name; entity.Description = model.Description; var permissionsArray = model.Permissions.Split(',').Select(x => Convert.ToInt32(x)).ToList(); var PermissionList = PermissionsService.GetALL().Where(x => permissionsArray.Contains(x.ID)); entity.Permissions.AddRange(PermissionList); RolesService.Create(entity); result.Message = "添加角色成功!"; LogHelper.WriteLog("添加角色成功"); return(RedirectToAction("index")); } catch (DbEntityValidationException ex) { result.Message = Utilities.GetInnerMostException(ex); result.AddServiceError(result.Message); LogHelper.WriteLog("添加角色错误", ex); return(View(model)); } } else { result.Message = "请检查表单是否填写完整!"; result.AddServiceError("请检查表单是否填写完整!"); return(View(model)); } }