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")); }
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")); }
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")); }