Exemplo n.º 1
0
 public IHttpActionResult CreateDialog(CreateDialogDTO createDialogDTO)
 {
     try
     {
         return(Ok(service.CreateDialog(createDialogDTO)));
     }
     catch (Exception e)
     {
         return(InternalServerError(e));
     }
 }
Exemplo n.º 2
0
        public int CreateDialog(CreateDialogDTO createDialogDTO)
        {
            var dialogToBeAdded = Db.Dialogs.FirstOrDefault(d => (d.User1Id == createDialogDTO.User1Id || d.User1Id == createDialogDTO.User2Id) &&
                                                            (d.User2Id == createDialogDTO.User1Id || d.User2Id == createDialogDTO.User2Id));

            if (dialogToBeAdded == null)
            {
                dialogToBeAdded = new Dialog
                {
                    User1Id              = createDialogDTO.User1Id,
                    User2Id              = createDialogDTO.User2Id,
                    LastMessageText      = null,
                    LastMessageCreatedAt = null
                };

                Db.Dialogs.Add(dialogToBeAdded);
                Db.SaveChanges();
            }

            return(dialogToBeAdded.DialogId);
        }
Exemplo n.º 3
0
 public int CreateDialog(CreateDialogDTO createDialogDTO)
 {
     return(DialogLogic.CreateDialog(createDialogDTO));
 }