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")); }
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> AddStory(StoryCreationDto storiesDto) { var slug = storiesDto.Title.Replace(" ", "-"); var date = DateTime.Now.ToShortDateString(); date = date.Replace("/", "-"); storiesDto.Slug = slug.Replace("?", "a") + "-date-" + date; var story = _mapper.Map <Story>(storiesDto); story.DatePosted = DateTime.Now; _repos.Add(story); if (await _repos.SaveAll()) { return(CreatedAtRoute("GetStory", new { slug = story.Slug }, story)); } return(BadRequest("failed")); }