public ActionResult <PagedObject <Group> > AddGroupPerson(
            [FromRoute]
            [Required(ErrorMessage = "DataAnnotationRequired")]
            [Guid(ErrorMessage = "DataAnnotationGuid")]
            string groupId,
            [FromRoute]
            [Required(ErrorMessage = "DataAnnotationRequired")]
            [Guid(ErrorMessage = "DataAnnotationGuid")]
            string personId,
            [FromBody]
            GroupPersonAddRequest request)
        {
            var groupGuid = Guid.Parse(groupId);
            var group     = _groupService.GetGroup(groupGuid);

            if (group == null)
            {
                return(ErrorObjectResultFactory.NotFound());
            }

            var personGuid = Guid.Parse(personId);
            var person     = _personService.GetPerson(personGuid);

            if (person == null)
            {
                return(ErrorObjectResultFactory.NotFound());
            }

            _groupService.AddGroupPerson(groupGuid, personGuid, request.PositionType);

            return(new OkResult());
        }
Beispiel #2
0
        public void AddGroupPerson_OK_すべての値を正常値で登録()
        {
            var groupId       = "00000000-3002-0000-0000-000000000000";
            var personId      = "00000000-1001-0000-0000-000000000000";
            var requestObject = new GroupPersonAddRequest
            {
                PositionType = PositionType.GENERAL_MANAGER.ToString(),
            };

            var request = new HttpRequestMessage(HttpMethod.Put, $"/api/v1/groups/{groupId}/persons/{personId}");

            request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", "normal-write");
            request.Content = new StringContent(JsonUtil.Serialize(requestObject), Encoding.UTF8, "application/json");
            var response = _httpclient.SendAsync(request).ConfigureAwait(false).GetAwaiter().GetResult();

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
        }
Beispiel #3
0
        public void AddGroupPerson_Forbidden_書き込みアクセス権のないアクセストークン()
        {
            var groupId       = "00000000-0000-0000-0000-000000000000";
            var personId      = "00000000-0000-0000-0000-000000000000";
            var requestObject = new GroupPersonAddRequest
            {
                PositionType = PositionType.STAFF.ToString(),
            };

            var request = new HttpRequestMessage(HttpMethod.Put, $"/api/v1/groups/{groupId}/persons/{personId}");

            request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", "normal-read");
            request.Content = new StringContent(JsonUtil.Serialize(requestObject), Encoding.UTF8, "application/json");
            var response = _httpclient.SendAsync(request).ConfigureAwait(false).GetAwaiter().GetResult();

            Assert.AreEqual(HttpStatusCode.Forbidden, response.StatusCode);
        }