Esempio n. 1
0
        public IActionResult CreateGroup(CreateGroup model)
        {
            int            result         = 0;
            var            url            = $"{Common.Common.ApiUrl}/group/creategroup";
            HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);

            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method      = "POST";
            using (var streamWrite = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                var json = JsonConvert.SerializeObject(model);
                streamWrite.Write(json);
            }
            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var resResult = streamReader.ReadToEnd();
                result = int.Parse(resResult);
            }

            if (result > 0)
            {
                TempData["Done"] = "Group create successfully";
            }
            ModelState.Clear();
            return(View(new CreateGroup()
            {
            }));
        }
Esempio n. 2
0
        public async Task <ActionResult> CreateGroup([FromBody] CreateGroup command)
        {
            command.UserId = User.GetUserId();
            await _groupService.CreateAsync(command);

            return(Ok(new { command.Id }));
        }
Esempio n. 3
0
        public ActionResult Create(CreateGroupForm form)
        {
            CreateGroup createGroup = new CreateGroup(_db, Requester(), form);
            var         g           = createGroup.Execute();

            return(RedirectToAction("Messages", new { g.Id }));
        }
Esempio n. 4
0
 public override Task <GroupResult> Create(CreateGroup request, ServerCallContext context)
 {
     return(Task.FromResult(new GroupResult()
     {
         GroupId = "1", Stauts = true
     }));
 }
        public Group CreateGroup(CreateGroup createGroup)
        {
            var request = BuildRequestAuthorization(POST_GROUP, Method.POST);

            request.AddJsonBody(createGroup);

            var response = WebClient.Execute <Group>(request);

            if (response.ResponseStatus == ResponseStatus.Completed && response.StatusCode == System.Net.HttpStatusCode.Created)
            {
                return(response.Data);
            }

            if (!string.IsNullOrWhiteSpace(response.ErrorMessage))
            {
                throw new Exception(response.ErrorMessage);
            }

            if (!string.IsNullOrWhiteSpace(response.StatusDescription) && !string.IsNullOrWhiteSpace(response.Content))
            {
                throw new Exception($"{response.StatusDescription} || {response.Content}");
            }

            return(null);
        }
Esempio n. 6
0
        private CreateGroup.Response CreateGroupHandler(CreateGroup command)
        {
            ITracer tracer = platform.Tracer;

            try
            {
                var group = platform.Query <ITeamGroup>().FirstOrDefault(p => p.Name == command.Name);
                if (group != null)
                {
                    return(new CreateGroup.Response {
                        Error = new ExecutionError(-1010, "不允许重复创建")
                    });
                }

                var entity = platform.Create <ITeamGroup>();
                entity.Name        = command.Name;
                entity.Description = command.Description;
                platform.Submit(entity);

                return(new CreateGroup.Response {
                    Id = entity.Id
                });
            }
            catch (Exception ex)
            {
                tracer.Write("Siemens-SimaticIT-Trace-BusinessLogic", Category.Error, ex.Message);
                return(new CreateGroup.Response {
                    Error = new ExecutionError(-1010, ex.Message)
                });
            }
        }
Esempio n. 7
0
        public static async Task <bool> CreateNewGroup(string groupId, string name, string description)
        {
            var client = new HttpClient();

            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", ConfigurationManager.AppSettings["keyApi"]);

            CreateGroup groupInfo = new CreateGroup
            {
                name     = name,
                userData = description
            };

            byte[] byteData = Encoding.UTF8.GetBytes(new JavaScriptSerializer().Serialize(groupInfo));

            using (var content = new ByteArrayContent(byteData))
            {
                content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                var response = await client.PutAsync(ConfigurationManager.AppSettings["serverLink"] + "persongroups/" + groupId, content);

                if (response.Content.ReadAsStringAsync().Result == "")
                {
                    return(true);
                }

                else
                {
                    Grupos.response = response.Content.ReadAsStringAsync().Result;
                    return(false);
                }
            }
        }
        public async Task <IActionResult> Create([FromBody] CreateGroup model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var dto = _mapper.Map <DtoGroup>(model);

            var result = await _groupService.CreateAsync(dto, UserId);

            if (!result.Succeeded)
            {
                return(UnprocessableEntity(result.Errors));
            }

            var newDto = result.Result;
            // TODO make GroupRole not by Id but by name
            await _groupMemberService.CreateAsync(new DtoGroupMember
            {
                GroupId     = newDto.Id,
                UserId      = UserId,
                GroupRoleId = 3
            }, UserId);

            // TODO Error checking
            return(CreatedAtAction(nameof(GetById), new { id = newDto.Id }, newDto));
        }
        public async Task <IActionResult> Update([FromBody] CreateGroup model, [FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var dto = await _groupService.GetById(id);

            if (!dto.Succeeded)
            {
                return(BadRequest(dto.Errors));
            }

            _mapper.Map(model, dto.Result);

            var result = await _groupService.UpdateAsync(dto.Result, UserId);

            if (!result.Succeeded)
            {
                return(UnprocessableEntity(result.Errors));
            }

            var newDto = result.Result;

            return(Ok(newDto));
        }
Esempio n. 10
0
        public ActionResult CreateGroup()
        {
            var leadList = GetLead();
            var model    = new CreateGroup();

            model.ListLead = leadList;
            return(View("_CreateGroup", model));
        }
Esempio n. 11
0
        public CreateGroup CreateGroup()
        {
            CreateGroup action = new CreateGroup();

            action.Client(client);
            action.Proxy(proxy);
            return(action);
        }
        private void CreateGroup_Click(object sender, EventArgs e)
        {
            this.Hide();
            CreateGroup createGroup = new CreateGroup();

            createGroup.Show();
            this.AddOwnedForm(createGroup);
        }
Esempio n. 13
0
        public Group Post([FromBody] CreateGroup group, int userId)
        {
            Group g = new Group()
            {
                Name = group.Name
            };

            return(groupRepository.Insert(g, userId));
        }
Esempio n. 14
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            CreateGroup.AddGestureRecognizer(new UITapGestureRecognizer(GoToAddParticipants));

            NavigationItem.HidesBackButton = true;
            UserTable.DataSource           = this;
            UserTable.Delegate             = this;
            SubscribeToViewModel();
        }
Esempio n. 15
0
        public async Task <HttpResponseMessage> CreateGroupAsync(CreateGroup greateGroup)
        {
            ResponseBase <string> response = new ResponseBase <string>();

            if (greateGroup.ToWxIds == null || greateGroup.ToWxIds.Count == 0)
            {
                response.Success = false;
                response.Code    = "400";
                response.Message = "用户列表不能为空";
                return(await response.ToHttpResponseAsync());
            }
            try
            {
                IList <MMPro.MM.MemberReq> list = new List <MMPro.MM.MemberReq>();
                var memberReqCurrent            = new MMPro.MM.MemberReq();
                memberReqCurrent.member         = new MMPro.MM.SKBuiltinString();
                memberReqCurrent.member.@string = greateGroup.WxId;
                list.Add(memberReqCurrent);
                foreach (var item in greateGroup.ToWxIds)
                {
                    var memberReq = new MMPro.MM.MemberReq();
                    memberReq.member         = new MMPro.MM.SKBuiltinString();
                    memberReq.member.@string = item;
                    list.Add(memberReq);
                }
                var result = wechat.CreateChatRoom(greateGroup.WxId, list.ToArray(), greateGroup.GroupName);
                if (result == null || result.baseResponse.ret != (int)MMPro.MM.RetConst.MM_OK)
                {
                    response.Success = false;
                    response.Code    = "501";
                    response.Message = result.baseResponse.errMsg.@string ?? "创建失败";
                }
                else
                {
                    response.Data    = result.chatRoomName.@string;
                    response.Message = "创建成功";
                }
            }
            catch (ExpiredException ex)
            {
                response.Success = false;
                response.Code    = "401";
                response.Message = ex.Message;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Code    = "500";
                response.Message = ex.Message;
            }
            return(await response.ToHttpResponseAsync());
        }
        private void MakeGroupBut_Click(object sender, RoutedEventArgs e)
        {
            CreateGroup createGroup;

            if (selected.Count > 0)
            {
                createGroup = new CreateGroup(selected, this);
            }
            else
            {
                createGroup = new CreateGroup(lastSelected, this);
            }
            createGroup.ShowDialog();
        }
Esempio n. 17
0
 public ActionResult CreateGroup(CreateGroup u)
 {
     if (u != null)
     {
         Group gr = new Group
         {
             HeadId         = u.Head.Id,
             Number         = u.Number,
             Specialization = u.Specialization
         };
         _groupService.AddGroup(gr);
     }
     return(RedirectToAction("Index", "Group"));
 }
Esempio n. 18
0
        public async Task <IActionResult> Create(CreateGroup model)
        {
            if (!ModelState.IsValid)
            {
            }
            var result = await _service.CreateOrUpdateGroup(new UpsertGroup { Name = model.Name, UserId = model.UserId, Description = model.Description });

            var viewModel = new GroupViewModel
            {
                Id          = result.Id,
                Name        = result.Name,
                Description = result.Description
            };

            return(Ok(viewModel));
        }
Esempio n. 19
0
        public ActionResult Create(CreateGroup form)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    groupRepository.Insert(new Group(form.Name), SessionManager.User.Id);
                    return(RedirectToAction("Index"));
                }

                return(View(form));
            }
            catch
            {
                return(View("Error"));
            }
        }
Esempio n. 20
0
        public ActionResult Edit(int id, CreateGroup form)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    groupRepository.Update(id, new Group(id, form.Name));
                    return(RedirectToAction("Index"));
                }

                return(View(form));
            }
            catch
            {
                return(View("Error"));
            }
        }
Esempio n. 21
0
        public async Task <IActionResult> CreateNewGroup(CreateGroup createGroup)
        {
            var result = await userService.CreateUserGroups(createGroup);

            if (result.IsSuccess)
            {
                return(new OkObjectResult(result.GroupName));
            }
            else if (!result.IsSuccess && result.IsDuplicate)
            {
                return(BadRequest(result.ErrorMessage));
            }
            else
            {
                return(NotFound(result.ErrorMessage));
            }
        }
Esempio n. 22
0
        public async Task Handle(CreateGroup message)
        {
            try
            {
                var item = await repository.Get(message.Id.ToString());

                if (item != null)
                {
                    throw new Exception($"Group with id: {message.Id} already exist");
                }
            }
            catch (AggregateNotFoundException)
            {
                // That is fine that id not used
            }
            var group = GroupSource.Create(message.Id, message.Name, message.ManagementId, message.Deleted);
            await repository.Save(group);
        }
Esempio n. 23
0
        /// <summary>
        ///     Creates a new group in a specific board.
        /// </summary>
        /// <param name="createGroup">The mutation model.</param>
        /// <returns></returns>
        public async Task <string> CreateGroup(CreateGroup createGroup)
        {
            var request = new GraphQLRequest
            {
                Query     = @"mutation request($boardId:Int! $name:String!) { create_group (board_id: $boardId, group_name: $name) { id } }",
                Variables = new
                {
                    boardId = createGroup.BoardId,
                    name    = createGroup.Name
                }
            };

            var result = await _graphQlHttpClient.SendMutationAsync <CreateGroupResponse>(request);

            ThrowResponseErrors(result.Errors);

            return(result.Data.Group.Id);
        }
Esempio n. 24
0
        public IApiResult Create(CreateGroup operation)
        {
            var result = operation.ExecuteAsync().Result;

            if (result is ValidationsOutput)
            {
                return(new ApiResult <List <ValidationItem> >()
                {
                    Data = ((ValidationsOutput)result).Errors
                });
            }
            else
            {
                return(new ApiResult <object>()
                {
                    Status = ApiResult <object> .ApiStatus.Success
                });
            }
        }
Esempio n. 25
0
        public async Task CreateAsync(CreateGroup command)
        {
            var foundGroup = await _groupRepository.GetAsync(command.Name);

            if (foundGroup != null)
            {
                throw new AppException($"Group with name ${command.Name} already exists.", AppErrorCode.ALREADY_EXISTS);
            }

            var group  = new Group(command.Id, command.Name);
            var author = await _userRepository.GetAsync(command.UserId);

            group.AddAdministrator(author);
            group.AddStudent(author);

            await _groupRepository.AddAsync(group);

            await _groupRepository.SaveChangesAsync();
        }
        public void LoadView(ViewType typeView)
        {
            switch (typeView)
            {
            case ViewType.MainMenu:
                MainMenu          view      = new MainMenu();
                MainMenuViewModel viewModel = new MainMenuViewModel(this);
                //связываем их с собой
                view.DataContext = viewModel;
                //отображаем
                this.Page.Content = view;
                break;

            case ViewType.CreateGroup:
                CreateGroup          CreateGroupView      = new CreateGroup();
                CreateGroupViewModel CreateGroupViewModel = new CreateGroupViewModel(this, weeksDataBase);
                CreateGroupView.DataContext = CreateGroupViewModel;
                this.Page.Content           = CreateGroupView;
                break;

            case ViewType.LoginGroup:
                LoginGroup          LoginGroupView      = new LoginGroup();
                LoginGroupViewModel LoginGroupViewModel = new LoginGroupViewModel(this, weeksDataBase);
                LoginGroupView.DataContext = LoginGroupViewModel;
                this.Page.Content          = LoginGroupView;
                break;

            case ViewType.WeekList:
                WeekList          WeekListView      = new WeekList();
                WeekListViewModel WeekListViewModel = new WeekListViewModel(this, weeksDataBase);
                WeekListView.DataContext = WeekListViewModel;
                this.Page.Content        = WeekListView;
                break;

            case ViewType.TimeTable:
                TimeTable          TimeTableView      = new TimeTable();
                TimeTableViewModel TimeTableViewModel = new TimeTableViewModel(this, weeksDataBase, disciplinesDataBase, TimeTableView);
                TimeTableView.DataContext = TimeTableViewModel;
                this.Page.Content         = TimeTableView;
                break;
            }
        }
        public ActionResult CreateGroup(CreateGroup model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            AppGroup group = new AppGroup()
            {
                Name       = model.Name,
                InviteCode = "12310",
                Creator    = new AppUser()
                {
                    Id = Guid.Parse(User.Identity.GetUserId())
                }
            };

            groupRepository.Save(group);
            return(RedirectToAction("Index", "Home"));
        }
Esempio n. 28
0
        void ReleaseDesignerOutlets()
        {
            if (CancelButton != null)
            {
                CancelButton.Dispose();
                CancelButton = null;
            }

            if (CreateGroup != null)
            {
                CreateGroup.Dispose();
                CreateGroup = null;
            }

            if (UserTable != null)
            {
                UserTable.Dispose();
                UserTable = null;
            }
        }
Esempio n. 29
0
        /// <summary>
        /// Post the specified request.
        /// </summary>
        /// <param name="request">Request.</param>
        public object Post(CreateGroup request)
        {
            var      context = TepWebContext.GetWebContext(PagePrivileges.AdminOnly);
            WebGroup result;

            try{
                context.Open();
                Group grp = (request.Id == 0 ? null : Group.FromId(context, request.Id));
                grp = request.ToEntity(context, grp);
                grp.Store();
                result = new WebGroup(grp);
                context.LogInfo(this, string.Format("/group POST Id='{0}'", grp.Id));
                context.LogDebug(this, string.Format("Group {0} created by user {1}", grp.Name, User.FromId(context, context.UserId).Username));
                context.Close();
            }catch (Exception e) {
                context.LogError(this, e.Message, e);
                context.Close();
                throw e;
            }
            return(result);
        }
Esempio n. 30
0
        public async Task Create([FromBody] CreateGroup body)
        {
            var groupId = $"{SpisumNames.Prefixes.Group}{body.Id}";

            try
            {
                var permissions = Enum.GetValues(typeof(GroupPermissionTypes)).Cast <GroupPermissionTypes>().Select(x => $"_{x}").ToList();
                permissions.Insert(0, "");                   // for basic name, for list all people in
                permissions.Add(SpisumNames.Postfixes.Sign); // for getting people who can sign

                foreach (var permission in permissions)
                {
                    await _alfrescoHttpClient.CreateGroup(new GroupBodyCreate
                    {
                        Id          = $"{groupId}{permission}",
                        DisplayName = $"{body.Name}{permission}"
                    });
                }

                // add to main group
                await _initialGroup.AddMainGroupMember(SpisumNames.Groups.MainGroup, groupId);

                if (body.Type?.ToLower() == "dispatch")
                {
                    await _initialGroup.AddMainGroupMember(SpisumNames.Groups.DispatchGroup, groupId);
                }
                else if (body.Type?.ToLower() == "repository")
                {
                    await _initialGroup.AddMainGroupMember(SpisumNames.Groups.RepositoryGroup, groupId);
                }

                await _initScript.ProcessGroup(groupId);
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Create group structure failed");
                await _alfrescoHttpClient.DeleteGroup(groupId);
            }
        }