コード例 #1
0
        public IHttpActionResult GetTransliterationListByUserId(TransliterationRequestModel model)
        {
            List <TransliterationModel> objList = new List <TransliterationModel>();

            try
            {
                var transList = _transService.GetTransliterationDetailsByUserId(model.User_Id);
                if (model.IsTTS == 1)
                {
                    transList = transList.Where(a => a.IsTTS == 1).ToList();
                }
                else if (model.IsSpellCheck == 1)
                {
                    transList = transList.Where(a => a.IsSpellCheck == 1).ToList();
                }
                else if (model.IsTranslate == 1)
                {
                    transList = transList.Where(a => a.IsTranslate == 1).ToList();
                }
                else if (model.IsFavourite == 1)
                {
                    transList = transList.Where(a => a.IsFavourite == 1).ToList();
                }
                foreach (var item in transList)
                {
                    TransliterationModel obj = new TransliterationModel();
                    obj.User_Id = item.User_Id;
                    obj.Details = item.Details;
                    if (item.IsFavourite == 1 && item.IsMoment == 1)
                    {
                        long momentId      = Convert.ToInt64(item.Details);
                        var  momentDetails = _momentsService.GetMomentDetailsById(momentId);
                        if (momentDetails != null && momentDetails.UserUploadedId > 0)
                        {
                            var userUploadedDetails = _userUploadsService.GetUserUploadsById(momentDetails.UserUploadedId);
                            if (userUploadedDetails != null)
                            {
                                obj.UploadedImagePath = userUploadedDetails.UploadedImagePath == null ? string.Empty : momentUploadImagePath + userUploadedDetails.UploadedImagePath;
                                obj.UploadedAudioPath = userUploadedDetails.UploadedAudioPath == null ? string.Empty : momentUploadAudioPath + userUploadedDetails.UploadedAudioPath;
                            }
                        }
                        else if (momentDetails != null)
                        {
                            obj.Message = momentDetails.Message;
                        }
                    }
                    if (string.IsNullOrEmpty(item.ImagePath))
                    {
                        obj.ImagePath = noImagePath;
                    }
                    else
                    {
                        var extension = item.ImagePath.Split('.')[1];
                        var imageName = item.ImagePath.Split('.')[0] + "_thumbnail";
                        obj.ImagePath = proImagePath + imageName + "." + extension;
                    }
                    // obj.ImagePath = item.ImagePath == null ? noImagePath : item.ImagePath == string.Empty ? noImagePath : proImagePath + item.ImagePath;
                    obj.Flag_Icon = imagePath + item.Flag_Icon;
                    objList.Add(obj);
                }
            }
            catch (Exception e)
            {
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e.Message)));
            }

            return(Ok(objList));
        }
コード例 #2
0
ファイル: ProcessInput.cs プロジェクト: Tanya5091/UnityClient
 private void InitiateTransliteration()
 {
     res           = TransliterationModel.Transliterate(src);
     threadRunning = false;
     Thread.Sleep(300);
 }
コード例 #3
0
        public IHttpActionResult InsertUserTransliterationDetails(TransliterationModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "User Id is required.")));
                }

                UserTransliterationDetails details = _transliterationService.GetTransliterationDetailsByUserId(model.User_Id);
                //TransliterationDetails transDetails = new TransliterationDetails();
                if (details != null)
                {
                    if (model.IsSpellCheck == 1)
                    {
                        details.SpellCheckCount = details.SpellCheckCount + 1;
                        // transDetails.IsSpellCheck = 1;
                    }
                    else if (model.IsTranslate == 1)
                    {
                        details.TranslateCount = details.TranslateCount + 1;
                        //transDetails.IsTranslate = 1;
                    }
                    else if (model.IsTTS == 1)
                    {
                        details.TTSCount = details.TTSCount + 1;
                        //transDetails.IsTTS = 1;
                    }
                    else
                    {
                        details.FavouritesCount = details.FavouritesCount + 1;
                        //transDetails.IsFavourite = 1;
                        //transDetails.IsMoment = 0;
                    }
                    ReturnMsg obj = _transliterationService.UpdateTransliterationByUserId(details);
                    if (!obj.IsSuccess)
                    {
                        return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "There is some error.")));
                    }
                    else
                    {
                        //transDetails.Details = model.Details;
                        //transDetails.User_Id = model.User_Id;
                        //_transService.InsertTransliteration(transDetails);
                    }
                }
                else
                {
                    details = new UserTransliterationDetails();
                    if (model.IsSpellCheck == 1)
                    {
                        details.SpellCheckCount = 1;
                        // transDetails.IsSpellCheck = 1;
                    }
                    else if (model.IsTranslate == 1)
                    {
                        details.TranslateCount = 1;
                        //transDetails.IsTranslate = 1;
                    }
                    else if (model.IsTTS == 1)
                    {
                        details.TTSCount = 1;
                        //transDetails.IsTTS = 1;
                    }
                    else
                    {
                        details.FavouritesCount = 1;
                        //transDetails.IsFavourite = 1;
                        // transDetails.IsMoment = 0;
                    }
                    //transDetails.Details = model.Details;
                    // transDetails.User_Id = model.User_Id;
                    details.User_Id = model.User_Id;
                    _transliterationService.InsertTransliterationDetails(details);
                    // _transService.InsertTransliteration(transDetails);
                }
            }
            catch (Exception e)
            {
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e.Message)));
            }

            return(Ok("Details inserted successfully."));
        }