コード例 #1
0
        public void RecordingCompleted(string path, string title)
        {
            try
            {
                TellMyself tell = new TellMyself();
                tell.TellType  = ConstantsAndTypes.TELL_TYPE.Audio;
                tell.TellText  = path.Trim();
                tell.TellTitle = title.Trim();
                Globals dbHelp = new Globals();
                dbHelp.OpenDatabase();
                var sqlDatabase = dbHelp.GetSQLiteDatabase();
                tell.Save(sqlDatabase);
                dbHelp.CloseDatabase();
                GlobalData.TellMyselfItemsList.Add(tell);
                Log.Info(TAG, "RecordingCompleted: Added recording " + title.Trim() + ", ID '" + tell.ID.ToString() + "'");

                UpdateAdapter();

                Toast.MakeText(this, GetString(Resource.String.RecordedAudioToast) + " '" + title + "'", ToastLength.Short).Show();
            }
            catch (Exception e)
            {
                Log.Error(TAG, "RecordingCompleted: Exception - " + e.Message);
                if (GlobalData.ShowErrorDialog)
                {
                    ErrorDisplay.ShowErrorAlert(this, e, GetString(Resource.String.ErrorCompletingTellMyselfAudio), "TellMyselfActivity.RecordingCompleted");
                }
            }
        }
コード例 #2
0
        //Required callback for generic text dialog entry
        public void ConfirmText(string textEntered, int genericTextID)
        {
            try
            {
                if (textEntered.Trim() == "")
                {
                    return;
                }

                TellMyself tell = new TellMyself();
                if (genericTextID != -1)
                {
                    tell.IsNew   = false;
                    tell.IsDirty = true;
                    tell.ID      = genericTextID;
                }
                else
                {
                    tell.IsDirty = false;
                    tell.IsNew   = true;
                }

                tell.TellType  = ConstantsAndTypes.TELL_TYPE.Textual;
                tell.TellText  = textEntered.Trim();
                tell.TellTitle = "";
                Globals dbHelp = new Globals();
                dbHelp.OpenDatabase();
                var sqlDatabase = dbHelp.GetSQLiteDatabase();
                tell.Save(sqlDatabase);
                dbHelp.CloseDatabase();

                if (genericTextID == -1)
                {
                    GlobalData.TellMyselfItemsList.Add(tell);
                    Log.Info(TAG, "ConfirmText: Added text " + textEntered.Trim() + ", ID '" + tell.ID.ToString() + "'");
                }
                else
                {
                    var index = GlobalData.TellMyselfItemsList.IndexOf(GlobalData.TellMyselfItemsList.Find(gen => gen.ID == genericTextID));
                    GlobalData.TellMyselfItemsList[index] = tell;
                    Log.Info(TAG, "ConfirmText: Updated text " + textEntered.Trim() + ", ID '" + tell.ID.ToString() + "'");
                }

                UpdateAdapter();

                Toast.MakeText(this, GetString(Resource.String.TellMyselfAddedToast) + " '" + textEntered + "'", ToastLength.Short).Show();
            }
            catch (Exception e)
            {
                Log.Error(TAG, "ConfirmText: Exception - " + e.Message);
                if (GlobalData.ShowErrorDialog)
                {
                    ErrorDisplay.ShowErrorAlert(this, e, GetString(Resource.String.ErrorTellMyselfAddText), "TellMyselfActivity.ConfirmText");
                }
            }
        }
コード例 #3
0
        public async Task <ActionResult <TellMyselfDto> > CreateTellMyself(int userId, CreateTellMyselfDto createTellMyselfDto)
        {
            var tellMyself = new TellMyself
            {
                TellText  = createTellMyselfDto.TellText,
                TellTitle = createTellMyselfDto.TellTitle,
                User      = await _unitOfWork.UserRepository.GetUserByIdAsync(userId)
            };

            _unitOfWork.TellMyselfRepository.AddItem(tellMyself);
            if (await _unitOfWork.Complete())
            {
                return(Ok(_mapper.Map <TellMyselfDto>(tellMyself)));
            }

            return(BadRequest("Unable to create Tell Myself"));
        }