Пример #1
0
        public async void deleteParticipant([FromUri] string groupName, [FromUri] string username)
        {
            var headerKey = "xAuthToken";
            var headers   = Request.Headers;

            var header = headers.GetValues(headerKey).FirstOrDefault(null);

            if (header != null)
            {
                string currentUsername = await mSessionsRepo.getUsername(header);

                string groupAdmin = await mGroupsRepo.getAdmin(groupName);

                if (currentUsername != null && groupAdmin != null && currentUsername == groupAdmin)
                {
                    mParticipantsRepo.deleteParticipant(groupName, username);
                }
            }
            throw new HttpResponseException(HttpStatusCode.BadRequest);
        }
Пример #2
0
        public async Task <GroupView> createGroup(Models.Group aGroup)
        {
            var headerKey = "xAuthToken";
            var headers   = Request.Headers;

            var header = headers.GetValues(headerKey).FirstOrDefault(null);

            string username = await mSessionsRepo.getUsername(header);

            if (username != null)
            {
                mGroupsRepo.createGroup(aGroup.name, username);
                return(new GroupView {
                    groupName = aGroup.name, groupAdmin = username, linked = false
                });
            }
            else
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }
        }