示例#1
0
        public async Task <IActionResult> CreateVideo(VideoCreateDto videoCreateDto)
        {
            var video = _mapper.Map <Video>(videoCreateDto);

            video.DatePosted = DateTime.Now;
            _repos.Add(video);
            if (await _repos.SaveAll())
            {
                return(CreatedAtRoute("GetVideo", new { id = video.Id }, video));
            }

            return(BadRequest("Failed adding video"));
        }
示例#2
0
        public async Task <IActionResult> GetStory(string slug)
        {
            var story = await _repos.GetStory(slug);

            story.Views++;

            if (await _repos.SaveAll())
            {
                return(Ok(story));
            }

            return(BadRequest("Failed to load resources"));
        }
示例#3
0
        public async Task <IActionResult> AddMessage(MessageDto messageDto)
        {
            var message = _mapper.Map <Message>(messageDto);

            _repos.Add(message);
            if (await _repos.SaveAll())
            {
                return(Ok("Message added successfully"));
            }

            return(BadRequest("Sorry, Failed to send message"));
        }