Example #1
0
        public IHttpActionResult InsertFavouriteDetails(FavouritesModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.Forbidden, "Sender Id and Reciever Id are required.")));
                }

                FavouritesDetails details = new FavouritesDetails();
                details.FavouriteUserId  = model.FavouriteUserId;
                details.IsSender         = model.IsSender;
                details.Message          = model.Message;
                details.MomentId         = model.MomentId;
                details.SenderRecieverId = model.SenderRecieverId;
                details.LocalMessageId   = model.LocalMessageId;
                var dateTime = DateTime.UtcNow;
                details.AddedDate = dateTime.ToString(@"yyyy/MM/dd hh:mm tt", new CultureInfo("en-US"));
                _favService.InsertFavourites(details);

                UserTransliterationDetails transliterationDetails = _transliterationService.GetTransliterationDetailsByUserId(details.FavouriteUserId);
                //TransliterationDetails transDetails = new TransliterationDetails();
                if (transliterationDetails != null)
                {
                    transliterationDetails.FavouritesCount = transliterationDetails.FavouritesCount + 1;

                    ReturnMsg obj = _transliterationService.UpdateTransliterationByUserId(transliterationDetails);
                }
                else
                {
                    transliterationDetails = new UserTransliterationDetails();

                    transliterationDetails.FavouritesCount = 1;

                    transliterationDetails.User_Id = model.FavouriteUserId;
                    _transliterationService.InsertTransliterationDetails(transliterationDetails);
                }
                //transDetails.IsFavourite = 1;
            }
            catch (Exception e)
            {
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e.Message)));
            }

            return(Ok("Favourites details inserted successfully."));
        }
Example #2
0
        public IHttpActionResult GetUserDetailsById(RequestModel model)
        {
            UserWithCountryIconInfo userDetails = new UserWithCountryIconInfo();

            try
            {
                List <HobbiesDetails> hobbiesList = new List <HobbiesDetails>();
                hobbiesList = _hobbiesService.GetAllHobbies();
                if (string.IsNullOrEmpty(model.Id))
                {
                    return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.Forbidden, "User Id is required.")));
                }
                long userId  = Convert.ToInt64(model.Id);
                var  details = _UserService.GetUserDetailsById(userId);
                if (details != null)
                {
                    userDetails.Address     = details.Address;
                    userDetails.Country_Id  = details.Country_Id;
                    userDetails.CreatedTime = details.CreatedTime;
                    userDetails.DeviceId    = details.DeviceId;
                    userDetails.Dob         = details.Dob;
                    userDetails.Email_Id    = details.Email_Id;
                    var countryDetails = _countryService.GetCountryDetailsById(details.Country_Id);
                    if (countryDetails != null)
                    {
                        userDetails.Flag_Icon = countryDetails.Flag_Icon;
                    }
                    userDetails.Gender    = details.Gender;
                    userDetails.Icon_Path = imagePath + countryDetails.Flag_Icon;
                }
                //userDetails.ImagePath = details.ImagePath == null ? noImagePath : details.ImagePath == string.Empty ? noImagePath : proImagePath + details.ImagePath;
                if (string.IsNullOrEmpty(details.ImagePath))
                {
                    userDetails.ImagePath = noImagePath;
                }
                else
                {
                    var extension = details.ImagePath.Split('.')[1];
                    var imageName = details.ImagePath.Split('.')[0] + "_thumbnail";
                    userDetails.ImagePath = proImagePath + imageName + "." + extension;
                }
                userDetails.Interests   = details.Interests;
                userDetails.IsVerified  = details.IsVerified;
                userDetails.LagLevel_ID = details.LagLevel_ID;
                var userLangDetails = _userLangService.GetLanguageListByUserId(details.User_Id);
                if (userLangDetails != null)
                {
                    var langDetails = _languageService.GetLanguageDetailsById(userLangDetails.Native_LanguageId);
                    userDetails.Native_LanguageId = userLangDetails.Native_LanguageId;
                    if (langDetails != null)
                    {
                        userDetails.NativeAbbrv = langDetails.Abbreviation;
                    }
                    langDetails = _languageService.GetLanguageDetailsById(userLangDetails.Learning_LanguageId);
                    userDetails.Learning_LanguageId = userLangDetails.Learning_LanguageId;
                    if (langDetails != null)
                    {
                        userDetails.LearningAbbrv = langDetails.Abbreviation;
                    }
                }
                userDetails.Name = details.Name;
                userDetails.Self_Introduction     = details.Self_Introduction;
                userDetails.TravelDestination_CId = details.TravelDestination_CId;
                userDetails.TrevoId = details.TrevoId;
                userDetails.User_Id = details.User_Id;

                var userHobbies = _hobbiesService.GetUserHobbiesByUserId(details.User_Id);
                foreach (var item in userHobbies)
                {
                    if (string.IsNullOrEmpty(userDetails.UserHobbies))
                    {
                        userDetails.UserHobbies = hobbiesList.Where(a => a.HobbiesId == item.HobbiesId).FirstOrDefault().Name;
                    }
                    else
                    {
                        userDetails.UserHobbies = userDetails.UserHobbies + " ," + hobbiesList.Where(a => a.HobbiesId == item.HobbiesId).FirstOrDefault().Name;
                    }
                }

                UserTransliterationDetails transliterationDetails = _transliterationService.GetTransliterationDetailsByUserId(userDetails.User_Id);
                if (transliterationDetails != null)
                {
                    userDetails.FavCount        = transliterationDetails.FavouritesCount;
                    userDetails.TTSCount        = transliterationDetails.TTSCount;
                    userDetails.SpellCheckCount = transliterationDetails.SpellCheckCount;
                    userDetails.TranslateCount  = transliterationDetails.TranslateCount;
                }
            }
            catch (Exception e)
            {
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e.Message)));
            }
            return(Ok(userDetails));
        }