Ejemplo n.º 1
0
        public async Task <IActionResult> Post([FromBody] VideoModel model, int time_offset = 0)
        {
            model.SetOffset((-1) * time_offset);

            //var video = GetVideo(model);
            var videos = GetVideos(model.Videos);

            var commandResult = await _commandHandler.Execute(new VideoCreateContext
            {
                //Video = video,
                Videos = videos
            });

            if (commandResult.IsSuccess)
            {
                //  var videoModel = await _videosQueries.GetById(video.Id);
                model.SetOffset(time_offset);
                return(Ok(/*videoModel*/));
            }
            else
            {
                return(BadRequest(new ApiResultCode(commandResult)));
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Put(int id, [FromBody] VideoModel model, int time_offset = 0)
        {
            model.SetOffset((-1) * time_offset);

            var videos = GetVideos(model.Videos);

            var commandResult = await _commandHandler.Execute(new VideoUpdateContext
            {
                Id     = id,
                Videos = videos
            });

            if (commandResult.IsSuccess)
            {
                var videosModel = await _videosQueries.GetById(id);

                videosModel.SetOffset(time_offset);
                return(Ok());
            }
            else
            {
                return(BadRequest(new ApiResultCode(commandResult)));
            }
        }