public IHttpActionResult CreateDialog(CreateDialogDTO createDialogDTO) { try { return(Ok(service.CreateDialog(createDialogDTO))); } catch (Exception e) { return(InternalServerError(e)); } }
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); }
public int CreateDialog(CreateDialogDTO createDialogDTO) { return(DialogLogic.CreateDialog(createDialogDTO)); }