public Message(PostMessageDTO m, Employee author) { Topic = m.Topic; Text = m.Text; Date = DateTime.Now; Author = author; }
public async Task <IActionResult> PostMessage(PostMessageDTO messageData) { if (!IsValidApiRequest()) { return(ApiBadRequest("Invalid Headers!")); } var user = await GetCurrentUser(); var message = new Message(messageData, user); await Context.Messages.AddAsync(message); await Context.SaveChangesAsync(); return(StatusCode(201)); }
public IHttpActionResult PostMessage(PostMessageDTO dto) { if (!ModelState.IsValid) { return BadRequest(ModelState); } var message = new Message { SourceId = Guid.NewGuid(), Content = dto.MessageContent }; TopicRepository.PostMessage(dto.TopicName, message); return CreatedAtRoute("DefaultApi", new { id = message.SourceId }, message); }
public void SavePostMessage(PostMessageDTO postToken, out string error, long?notificationId = null) { error = string.Empty; try { var entity = postToken.Dto2FbPostInterfaceEntity(notificationId); FacebookPostRepository.Add(entity); FacebookPostRepository.UnitOfWork.CommitAndRefreshChanges(); } catch (Exception ex) { error = Utils.FormatError(ex); Logger.Error("save FB message", postToken.MessageId ?? -1, ex, CommonEnums.LoggerObjectTypes.FB); } }
public static FB_PostInterface Dto2FbPostInterfaceEntity(this PostMessageDTO token, long?notificationId = null) { return(new FB_PostInterface { UserId = token.UserId , FbUid = token.UserFbId , Title = token.MessageTitle , Message = token.MessageText , LinkedName = token.MessageUrl , Caption = token.Caption , Description = token.Description , ImageUrl = token.ImageUrl , ActionId = token.Action == null ? null : (byte?)token.Action , AddOn = DateTime.Now , Status = FbEnums.ePostInterfaceStatus.Waiting.ToString() , NotificationId = notificationId , IsAppPagePost = token.IsAppPagePost , CourseId = token.CourseId , ChapterVideoId = token.ChapterVideoID }); }