コード例 #1
0
        public async Task <IActionResult> Post([FromBody] FeedChannelViewModel channel)
        {
            var user = await _userService.GetCurrentUser();

            var channelEntity = channel.ToEntity();

            channelEntity.UserId = user.Id;
            await _channelService.Add(channelEntity);

            return(Ok());
        }
コード例 #2
0
        public async Task <IActionResult> Put(string id, [FromBody] FeedChannelViewModel channel)
        {
            var user = await _userService.GetCurrentUser();

            var channelInStore = await _channelService.Get(id);

            if (!channelInStore.UserId.Equals(user.Id, StringComparison.OrdinalIgnoreCase))
            {
                Response.StatusCode = (int)HttpStatusCode.Forbidden;
                return(BadRequest());
            }
            var channelEntity = channel.ToEntity();

            channelEntity.Id     = channelInStore.Id;
            channelEntity.UserId = channelInStore.UserId;
            await _channelService.Update(user, channelEntity);

            return(Ok());
        }