public static ChatEvent ToChatEvent(this ChatEventDataModel value) { return(new ChatEvent() { Actor = value.ActorId, Type = value.EventType, UserInvolved = value.UserInvolvedId, ActorName = value.Actor?.UserName, UserInvolvedName = value.UserInvolved?.UserName }); }
public async Task <MessageDataModel> AddChatEvent(ChatEventType type, string actorId, string userInvolvedId, int chatId) { try { var newEvent = await chatEventsRepository.AddAsync(ChatEventDataModel.Create(actorId, userInvolvedId, type)); var model = MessageDataModel .Create(null, chatId) .AsEvent(newEvent); var result = await messagesRepository.AddAsync(model); await unitOfWork.Commit(); return(result); } catch (Exception e) { throw new InvalidDataException("Wrong actorId or userId", e); } }
public static MessageDataModel AsEvent(this MessageDataModel value, ChatEventDataModel cEventDto) { value.Event = cEventDto; value.Type = MessageType.Event; return(value); }