public async Task<IHttpActionResult> Post(ProfileRequestModel profile)
        {
            if (!ModelState.IsValid)
            {
                return this.BadRequest(this.ModelState);
            }
            var newFirstName = profile.FirstName;
            var newLastName = profile.LastName;
            var newCity = profile.City;
            var newPhone = profile.Phone;
            var newAbout = profile.About;

            var existingProfile = await this.UsersService
                .ByUsername(User.Identity.Name)
                .FirstOrDefaultAsync();

            await this.UsersService.UpdateUser(
                this.mappingService.Map(profile, existingProfile),
                newFirstName,
                newLastName,
                newCity,
                newPhone,
                newAbout
                );

            return this.Ok(this.mappingService.Map<ProfileResponseModel>(existingProfile));
            //return this.Ok(this.Get(User.Identity.Name));
        }
        public async Task <IHttpActionResult> Post(ProfileRequestModel profile)
        {
            if (!ModelState.IsValid)
            {
                return(this.BadRequest(this.ModelState));
            }
            var newFirstName = profile.FirstName;
            var newLastName  = profile.LastName;
            var newCity      = profile.City;
            var newPhone     = profile.Phone;
            var newAbout     = profile.About;

            var existingProfile = await this.UsersService
                                  .ByUsername(User.Identity.Name)
                                  .FirstOrDefaultAsync();

            await this.UsersService.UpdateUser(
                this.mappingService.Map(profile, existingProfile),
                newFirstName,
                newLastName,
                newCity,
                newPhone,
                newAbout
                );

            return(this.Ok(this.mappingService.Map <ProfileResponseModel>(existingProfile)));
            //return this.Ok(this.Get(User.Identity.Name));
        }
        public HttpResponseMessage PutV2(ProfileRequestModel profile)
        {
            if (profile.Biography.Length > 1024)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Biography must be below 1024 chars in length."));
            }
            var access = UserRights.V2Login(Db, Request);

            if (access.HasErrors)
            {
                return(Request.CreateErrorResponse(access.ErrorCode, access.ErrorMessage));
            }

            access.Session.C_records.ProfileBiography = profile.Biography;
            Db.SaveChanges();
            return(Request.CreateResponse(HttpStatusCode.OK));
        }
        public async Task <ProfileUpdateSuccessModel> Put(ProfileRequestModel profile)
        {
            var username = GetUserNameFromRequest(Request);
            var user     = Db.C_records.SingleOrDefault(r => r.username == username);

            ProfileUpdateSuccessModel response = new ProfileUpdateSuccessModel();

            if (profile.Biography.Length > 1024)
            {
                response.SetError(400, "Biography must be below 1024 chars in length.");
                return(response);
            }
            if (user != null)
            {
                user.ProfileBiography = profile.Biography;
            }
            await Db.SaveChangesAsync();

            return(response);
        }
        /// <summary>
        /// To Call Get Searches Api..
        /// </summary>
        /// <param name="request"></param>
        /// <param name="success"></param>
        /// <param name="failed"></param>
        /// <returns></returns>
        public async Task <SearchResponseModel> SearchesApi(ProfileRequestModel request, Action <object> success, Action <object> failed)
        {
            SearchResponseModel resmodel = new SearchResponseModel();

            try
            {
                var    url        = string.Format("{0}/api/appconnect/Searches", WebServiceDetails.BasUri);
                string randomGuid = Guid.NewGuid().ToString();
                var    dic        = new Dictionary <string, string>();
                dic.Add("randomguid", randomGuid);
                dic.Add("hash", randomGuid + WebServiceDetails.AppKey + request.profiletoken + Helpers.LocalStorage.GeneralSecretkey);

                var result = await _apiProvider.Post <SearchResponseModel, ProfileRequestModel>(url, request, dic);

                var response = result.RawResult;
                Helpers.LocalStorage.GeneralSearches = result.RawResult;
                resmodel = JsonConvert.DeserializeObject <SearchResponseModel>(response);

                if (result.IsSuccessful == true)
                {
                    if (resmodel.responsecode == 100)
                    {
                        success.Invoke(resmodel);
                    }
                    else
                    {
                        failed.Invoke(resmodel);
                    }
                }
                else
                {
                    failed.Invoke(resmodel);
                }
            }
            catch (Exception exception)
            {
                UserDialogs.Instance.HideLoading();
            }
            return(resmodel);
        }