public GroupEditModel SaveNewGroup(GroupEditModel model) { //Check to make sure there are values if (model.GroupName == null) { throw new Exception("Name is Required"); } if (model.GroupName == "abc123") { throw new AppException("You are dumb"); } //code to get the currently logged in user //var liu = _httpContextAccessor.HttpContext.User; //var u = CustomUserModelByLoggedInUser(liu); var u = GetLoggedInUser(); //Save the new group var saved = _groupDal.SaveNewGroup(model); model.Update(saved); //Now we will add the user who is creating the group to the new group var gmd = new GroupMembershipEditModel(); //gmd.AccountNumberString = ""; gmd.AccountNumberString = u.AccountNumberString; gmd.GroupId = saved.GroupId; _groupMembershipDal.SaveMemberToGroup(gmd); model.Saved = true; return(model); }
public ActionResult Edit(GroupEditModel model) { try { var group = new Group { Id = new Identity(model.Group.Id), Name = model.Group.Name, Description = model.Group.Description, ParentId = model.Group.ParentId == null ? new Identity?() : new Identity(model.Group.ParentId) }; updateGroupCommand.Execute(group); return(RedirectToAction("Index")); } catch (Exception e) { ModelState.AddModelError(Guid.NewGuid().ToString(), e); } model.GroupList = GetGroupList(new Identity(model.Group.Id)); return(View(model)); }
//[Route("tickets/{department}/newcategoryonticketview/edit")] public ActionResult SaveNewGroup(GroupEditModel model) { if (!ModelState.IsValid) { return(View("NewGroup", model)); } try { //save the new group - get the ID var m = _secretSantaBl.SaveNewGroup(model); var grouphome = _secretSantaBl.GroupHomeEditModelByGroupId(m.GroupId); grouphome.NewGroup = true; return(RedirectToAction("GroupHome", new { id = m.GroupId })); } catch (AppException ax) { ModelState.AddModelError("", ax.AppMessage); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); _log.LogWarning(ex.Message); } return(View("NewGroup", model)); }
//[Route("tickets/{department}/newcategoryonticketview/edit")] public ActionResult SaveGroup(GroupEditModel model) { if (!ModelState.IsValid) { return(View("NewGroup", model)); } try { //save the new group - get the ID var m = _secretSantaBl.SaveGroup(model); m.Saved = true; return(PartialView("_EditGroupPopup", m)); //return RedirectToAction("GroupHome", new { id = m.GroupId }); } catch (AppException ax) { ModelState.AddModelError("", ax.AppMessage); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); _log.LogWarning(ex.Message); } return(PartialView("_EditGroupPopup", model)); }
public ActionResult Edit(string id) { var groupId = new Identity(id); var group = entityById.Get <Group>(groupId); if (group == null) { return(View("GroupDoesNotExist")); } var model = new GroupEditModel { Group = new GroupModel { Id = group.Id.ToString(), Name = group.Name, Description = group.Description, ParentId = group.ParentId.ToString() }, GroupList = GetGroupList(groupId) }; return(View(model)); }
public ActionResult Group(GroupEditModel gm) { if (gm.Group.IsNew) { ViewBag.Title = Piranha.Resources.Settings.EditTitleNewGroup; } else { ViewBag.Title = Piranha.Resources.Settings.EditTitleExistingGroup; } if (ModelState.IsValid) { try { if (gm.SaveAll()) { ModelState.Clear(); ViewBag.Title = Piranha.Resources.Settings.EditTitleExistingGroup; SuccessMessage(Piranha.Resources.Settings.MessageGroupSaved); } else { ErrorMessage(Piranha.Resources.Settings.MessageGroupNotSaved); } } catch (Exception e) { ErrorMessage(e.ToString()); } } gm.Refresh(); return(View(@"~/Areas/Manager/Views/Settings/Group.cshtml", gm)); }
public async Task <bool> UpdateAsync(GroupEditModel model) { if (model == null || model.Id <= 0) { return(ToResponse(false, Errors.invalid_data)); } if (string.IsNullOrWhiteSpace(model.Name) || string.IsNullOrWhiteSpace(model.ShortName)) { return(ToResponse(false, "Vui lòng nhập tên nhóm")); } if (model.MemberIds == null) { model.MemberIds = new List <int>(); } string parentSequenceCode = "0"; if (model.ParentId > 0) { var parentCodeResponse = await _rpGroup.GetParentSequenceCodeAsync(model.ParentId); if (parentCodeResponse.success) { parentSequenceCode = parentCodeResponse.data + "." + model.ParentId; } } model.MemberIds = model.MemberIds != null?model.MemberIds.Distinct().ToList() : new List <int>(); return(ToResponse(await _rpGroup.UpdateAsync(model, parentSequenceCode, _process.User.OrgId))); }
public async Task <BaseResponse <bool> > UpdateAsync(GroupEditModel model, string parentSequenceCode, int orgId) { try { using (var con = GetConnection()) { var result = await con.ExecuteAsync("sp_Group_Update", new { Id = model.Id, parentId = model.ParentId, LeaderId = model.LeaderId, ShortName = model.ShortName, Name = model.Name, parentSequenceCode, orgId, memberIds = string.Join(',', model.MemberIds) }, commandType : CommandType.StoredProcedure); return(BaseResponse <bool> .Create(true)); } } catch (Exception ex) { return(BaseResponse <bool> .Create(false, GetException(ex))); } }
public async Task <IHttpActionResult> Edit(GroupEditModel model) { var group = _groupService.Get(model.Id); if (group == null || group.IsHidden) { return(NotFound()); } if (!_groupService.CanEdit(group)) { return(StatusCode(HttpStatusCode.Forbidden)); } group = Mapper.Map(model, group); group.ImageId = model.Media?.Split(',').First().ToNullableInt(); var createdMedias = _mediaHelper.CreateMedia(model, MediaFolderTypeEnum.GroupsContent).ToList(); if (createdMedias.Any()) { group.ImageId = createdMedias.First(); } await _groupService.EditAsync(group); await _groupMediaService.GroupTitleChangedAsync(group.Id, group.Title); return(Ok(_groupLinkProvider.GetGroupRoomLink(group.Id))); }
public GroupEditModel GroupEditModelByGroupId (int id) { var group = _groupDal.GetGroupById (id); if (group == null) throw new AppException ($"Error loading Group by ID: {id}"); var result = new GroupEditModel (); result.Update (group); result.GroupId = group.GroupId; return result; }
public ActionResult Group(string id) { if (!String.IsNullOrEmpty(id)) { ViewBag.Title = Piranha.Resources.Settings.EditTitleExistingGroup; return(View(@"~/Areas/Manager/Views/Settings/Group.cshtml", GroupEditModel.GetById(new Guid(id)))); } else { ViewBag.Title = Piranha.Resources.Settings.EditTitleNewGroup; return(View(@"~/Areas/Manager/Views/Settings/Group.cshtml", new GroupEditModel())); } }
public GroupEditModel SaveGroup (GroupEditModel model) { if (model.GroupName == null) throw new Exception ("Name is Required"); var group = new Group (); group.Update (model); group.GroupId = model.GroupId; var saved = _groupDal.SaveGroup (group); model.Update (saved); return model; }
public ActionResult DeleteGroup(string id) { GroupEditModel gm = GroupEditModel.GetById(new Guid(id)); ViewBag.SelectedTab = "groups"; if (gm.DeleteAll()) { SuccessMessage(Piranha.Resources.Settings.MessageGroupDeleted); } else { ErrorMessage(Piranha.Resources.Settings.MessageGroupNotDeleted); } return(GroupList()); }
public ActionResult Create() { pageResourceManager.InsertTitlePart("创建群组"); string errorMessage = null; if (!new Authorizer().Group_Create(out errorMessage)) { return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Body = errorMessage, Title = errorMessage, StatusMessageType = StatusMessageType.Error }))); } GroupEditModel group = new GroupEditModel(); return(View(group)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] GroupEditModel group) { if (id != group.Id) { return(NotFound()); } if (ModelState.IsValid) { await groupService.UpdateGroupAsync(new GroupDTO { Id = group.Id, Name = group.Name }); return(RedirectToAction("Details", "Group", new { id })); } return(View(group)); }
public ActionResult Edit(GroupEditModel model) { if (!ModelState.IsValid) { return(RedirectToCurrentUmbracoPage(Request.QueryString)); } var group = _groupService.Get(model.Id); group = Mapper.Map(model, group); group.ImageId = model.Media?.Split(',').First().ToNullableInt(); var createdMedias = _mediaHelper.CreateMedia(model).ToList(); if (createdMedias.Any()) { group.ImageId = createdMedias.First(); } _groupService.Edit(group); _groupMediaService.GroupTitleChanged(group.Id, group.Title); return(Redirect(_groupLinkProvider.GetGroupLink(group.Id))); }
public ActionResult EditGroup(string spaceKey) { GroupEntity group = groupService.Get(spaceKey); //已修改 if (group == null) { return(HttpNotFound()); } pageResourceManager.InsertTitlePart(group.GroupName); pageResourceManager.InsertTitlePart("编辑群组"); //编辑的时候需要显示已添加的标签 IEnumerable <string> tags = group.TagNames; GroupEditModel groupEditModel = group.AsEditModel(); ViewData["tags"] = tags; TempData["GroupMenu"] = GroupMenu.GroupSettings; return(View(groupEditModel)); }
public ActionResult Group(GroupEditModel gm) { if (gm.Group.IsNew) { ViewBag.Title = Piranha.Resources.Settings.EditTitleNewGroup; } else { ViewBag.Title = Piranha.Resources.Settings.EditTitleExistingGroup; } // Check so that no groups are saved without a parent except the system administrator. if (gm.Group.ParentId == Guid.Empty && gm.Group.Id != Config.SysAdminGroupId) { ModelState.AddModelError("Group.ParentId", Resources.Settings.GroupParentIdRequired); } if (ModelState.IsValid) { try { if (gm.SaveAll()) { ModelState.Clear(); ViewBag.Title = Piranha.Resources.Settings.EditTitleExistingGroup; SuccessMessage(Piranha.Resources.Settings.MessageGroupSaved); } else { ErrorMessage(Piranha.Resources.Settings.MessageGroupNotSaved); } } catch (Exception e) { ErrorMessage(e.ToString()); } } gm.Refresh(); return(View(@"~/Areas/Manager/Views/Settings/Group.cshtml", gm)); }
public ActionResult EditGroup(string spaceKey, GroupEditModel groupEditModel) { IUser currentUser = UserContext.CurrentUser; if (currentUser == null) { return(Json(new StatusMessageData(StatusMessageType.Error, "您尚未登录!"))); } System.IO.Stream stream = null; HttpPostedFileBase groupLogo = Request.Files["GroupLogo"]; if (groupLogo != null && !string.IsNullOrEmpty(groupLogo.FileName)) { TenantLogoSettings tenantLogoSettings = TenantLogoSettings.GetRegisteredSettings(TenantTypeIds.Instance().Group()); if (!tenantLogoSettings.ValidateFileLength(groupLogo.ContentLength)) { ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, string.Format("文件大小不允许超过{0}", Formatter.FormatFriendlyFileSize(tenantLogoSettings.MaxLogoLength * 1024))); return(View(groupEditModel)); } LogoSettings logoSettings = DIContainer.Resolve <ILogoSettingsManager>().Get(); if (!logoSettings.ValidateFileExtensions(groupLogo.FileName)) { ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, "不支持的文件类型,仅支持" + logoSettings.AllowedFileExtensions); return(View(groupEditModel)); } stream = groupLogo.InputStream; groupEditModel.Logo = groupLogo.FileName; } GroupEntity group = groupEditModel.AsGroupEntity(); //设置分类 if (groupEditModel.CategoryId > 0) { categoryService.ClearCategoriesFromItem(group.GroupId, 0, TenantTypeIds.Instance().Group()); categoryService.AddItemsToCategory(new List <long>() { group.GroupId }, groupEditModel.CategoryId, 0); } //已修改 //设置标签 string relatedTags = Request.Form.Get <string>("RelatedTags"); if (!string.IsNullOrEmpty(relatedTags)) { tagService.ClearTagsFromItem(group.GroupId, group.GroupId); tagService.AddTagsToItem(relatedTags, group.GroupId, group.GroupId); } if (stream != null) { groupService.UploadLogo(group.GroupId, stream); } groupService.Update(currentUser.UserId, group); TempData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Success, "更新成功!"); return(Redirect(SiteUrls.Instance().EditGroup(group.GroupKey))); }
public async Task <IActionResult> Edit(int id) { var group = await groupService.GetGroupByIdAsync(id); return(View("Edit", GroupEditModel.FromDTO(group))); }
public ActionResult Create(GroupEditModel groupEditModel) { string errorMessage = null; if (ModelState.HasBannedWord(out errorMessage)) { return Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Body = errorMessage, Title = "创建失败", StatusMessageType = StatusMessageType.Hint })); } System.IO.Stream stream = null; HttpPostedFileBase groupLogo = Request.Files["GroupLogo"]; //已修改 IUser user = UserContext.CurrentUser; if (user == null) return Json(new StatusMessageData(StatusMessageType.Error, "您尚未登录!")); if (!authorizer.Group_Create(out errorMessage)) { return Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Body = errorMessage, Title = errorMessage, StatusMessageType = StatusMessageType.Hint })); } if (groupLogo != null && !string.IsNullOrEmpty(groupLogo.FileName)) { TenantLogoSettings tenantLogoSettings = TenantLogoSettings.GetRegisteredSettings(TenantTypeIds.Instance().Group()); if (!tenantLogoSettings.ValidateFileLength(groupLogo.ContentLength)) { ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, string.Format("文件大小不允许超过{0}", Formatter.FormatFriendlyFileSize(tenantLogoSettings.MaxLogoLength * 1024))); return View(groupEditModel); } LogoSettings logoSettings = DIContainer.Resolve<ISettingsManager<LogoSettings>>().Get(); if (!logoSettings.ValidateFileExtensions(groupLogo.FileName)) { ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, "不支持的文件类型,仅支持" + logoSettings.AllowedFileExtensions); return View(groupEditModel); } stream = groupLogo.InputStream; groupEditModel.Logo = groupLogo.FileName; } GroupEntity group = groupEditModel.AsGroupEntity(); bool result = groupService.Create(user.UserId, group); if (stream != null) { groupService.UploadLogo(group.GroupId, stream); } //设置分类 if (groupEditModel.CategoryId > 0) { categoryService.AddItemsToCategory(new List<long>() { group.GroupId }, groupEditModel.CategoryId); } //设置标签 string relatedTags = Request.Form.Get<string>("RelatedTags"); if (!string.IsNullOrEmpty(relatedTags)) { tagService.AddTagsToItem(relatedTags, group.GroupId, group.GroupId); } //发送邀请 if (!string.IsNullOrEmpty(groupEditModel.RelatedUserIds)) { //已修改 IEnumerable<long> userIds = Request.Form.Gets<long>("RelatedUserIds", null); groupService.SendInvitations(group, user, string.Empty, userIds); } return Redirect(SiteUrls.Instance().GroupHome(group.GroupKey)); }
public ActionResult Create() { pageResourceManager.InsertTitlePart("创建群组"); string errorMessage = null; if (!authorizer.Group_Create(out errorMessage)) { return Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Body = errorMessage, Title = errorMessage, StatusMessageType = StatusMessageType.Hint })); } GroupEditModel group = new GroupEditModel(); return View(group); }
public ActionResult Create(GroupEditModel groupEditModel) { string errorMessage = null; if (ModelState.HasBannedWord(out errorMessage)) { return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Body = errorMessage, Title = "创建失败", StatusMessageType = StatusMessageType.Error }))); } System.IO.Stream stream = null; HttpPostedFileBase groupLogo = Request.Files["GroupLogo"]; //已修改 IUser user = UserContext.CurrentUser; if (user == null) { return(Json(new StatusMessageData(StatusMessageType.Error, "您尚未登录!"))); } if (!new Authorizer().Group_Create(out errorMessage)) { return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Body = errorMessage, Title = errorMessage, StatusMessageType = StatusMessageType.Error }))); } if (groupLogo != null && !string.IsNullOrEmpty(groupLogo.FileName)) { TenantLogoSettings tenantLogoSettings = TenantLogoSettings.GetRegisteredSettings(TenantTypeIds.Instance().Group()); if (!tenantLogoSettings.ValidateFileLength(groupLogo.ContentLength)) { ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, string.Format("文件大小不允许超过{0}", Formatter.FormatFriendlyFileSize(tenantLogoSettings.MaxLogoLength * 1024))); return(View(groupEditModel)); } LogoSettings logoSettings = DIContainer.Resolve <ILogoSettingsManager>().Get(); if (!logoSettings.ValidateFileExtensions(groupLogo.FileName)) { ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, "不支持的文件类型,仅支持" + logoSettings.AllowedFileExtensions); return(View(groupEditModel)); } stream = groupLogo.InputStream; groupEditModel.Logo = groupLogo.FileName; } GroupEntity group = groupEditModel.AsGroupEntity(); bool result = groupService.Create(user.UserId, group); if (stream != null) { groupService.UploadLogo(group.GroupId, stream); } //设置分类 if (groupEditModel.CategoryId > 0) { categoryService.AddItemsToCategory(new List <long>() { group.GroupId }, groupEditModel.CategoryId, 0); } //设置标签 string relatedTags = Request.Form.Get <string>("RelatedTags"); if (!string.IsNullOrEmpty(relatedTags)) { tagService.AddTagsToItem(relatedTags, group.GroupId, group.GroupId); } //发送邀请 if (!string.IsNullOrEmpty(groupEditModel.RelatedUserIds)) { //已修改 IEnumerable <long> userIds = Request.Form.Gets <long>("RelatedUserIds", null); groupService.SendInvitations(group, user, string.Empty, userIds); } return(Redirect(SiteUrls.Instance().GroupHome(group.GroupKey))); }
public ActionResult EditGroup(string spaceKey, GroupEditModel groupEditModel) { IUser currentUser = UserContext.CurrentUser; if (currentUser == null) return Json(new StatusMessageData(StatusMessageType.Error, "您尚未登录!")); System.IO.Stream stream = null; HttpPostedFileBase groupLogo = Request.Files["GroupLogo"]; if (groupLogo != null && !string.IsNullOrEmpty(groupLogo.FileName)) { TenantLogoSettings tenantLogoSettings = TenantLogoSettings.GetRegisteredSettings(TenantTypeIds.Instance().Group()); if (!tenantLogoSettings.ValidateFileLength(groupLogo.ContentLength)) { ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, string.Format("文件大小不允许超过{0}", Formatter.FormatFriendlyFileSize(tenantLogoSettings.MaxLogoLength * 1024))); return View(groupEditModel); } LogoSettings logoSettings = DIContainer.Resolve<ISettingsManager<LogoSettings>>().Get(); if (!logoSettings.ValidateFileExtensions(groupLogo.FileName)) { ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, "不支持的文件类型,仅支持" + logoSettings.AllowedFileExtensions); return View(groupEditModel); } stream = groupLogo.InputStream; groupEditModel.Logo = groupLogo.FileName; } GroupEntity group = groupEditModel.AsGroupEntity(); //设置分类 if (groupEditModel.CategoryId > 0) { categoryService.ClearCategoriesFromItem(group.GroupId, 0, TenantTypeIds.Instance().Group()); categoryService.AddItemsToCategory(new List<long>() { group.GroupId }, groupEditModel.CategoryId); } //已修改 //设置标签 string relatedTags = Request.Form.Get<string>("RelatedTags"); if (!string.IsNullOrEmpty(relatedTags)) { tagService.ClearTagsFromItem(group.GroupId, group.GroupId); tagService.AddTagsToItem(relatedTags, group.GroupId, group.GroupId); } if (stream != null) { groupService.UploadLogo(group.GroupId, stream); } groupService.Update(currentUser.UserId, group); TempData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Success, "更新成功!"); return Redirect(SiteUrls.Instance().EditGroup(group.GroupKey)); }
public GroupEditModel DefaultGroupEditModel() { var result = new GroupEditModel(); return(result); }
public ActionResult Edit(Guid groupId) { GroupEditModel model = GetEditModel(groupId); return(PartialView(EditViewPath, model)); }
public async Task <IActionResult> Update(int id, [FromBody] GroupEditModel model) { var result = await _bizGroup.UpdateAsync(model); return(ToResponse(result)); }