public HttpResponseMessage Update(long fpuserid)
        {
            if (!IsEnableAnonymous)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new
                {
                    FPUserID = 0
                }));
            }
            AnonymousDetail result = null;

            try
            {
                result = AnonymousDBContext.UpdateLastVisit(fpuserid).SingleOrDefault();
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.Message, ex);
            }

            if (result != null)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new
                {
                    FPUserID = Convert.ToInt64(result.FPUserID)
                }));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new
                {
                    FPUserID = 0
                }));
            }
        }
 protected override void Dispose(bool disposing)
 {
     if (AnonymousDBContext != null)
     {
         AnonymousDBContext.Dispose();
     }
     base.Dispose(disposing);
 }
        public HttpResponseMessage Create()
        {
            var fpuserId = 0M;

            try
            {
                if (IsEnableAnonymous)
                {
                    fpuserId = Convert.ToInt64(AnonymousDBContext.Create().SingleOrDefault());
                }
                else
                {
                    fpuserId = Convert.ToInt32(ConfigurationManager.AppSettings["AnonymousCookieDefaultValue"]);
                }
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.Message, ex);
            }
            return(Request.CreateResponse(HttpStatusCode.OK, new { FPUserID = fpuserId }));
        }
        public HttpResponseMessage UpdateProfileIdBasedOnGuid(long fpuserid, Guid personGuid)
        {
            if (!IsEnableAnonymous)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new
                {
                    FPUserID = 0
                }));
            }
            if (personGuid == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NoContent, new HttpError(ErrorInfo.UserNotFound)));
            }
            var result = 0;
            //var person = ProfileDbContext.People.Where(p => p.PersonGuid.Equals(personGuid)).FirstOrDefault();
            var personDetails = ProfileDbContext.PersonDetails.Where(p => p.FinanceServiceGuid.Equals(personGuid)).FirstOrDefault();

            //*IMPORTANT--* As per suggestions from Vishal to Bharat (28/7/2014): in UnknownUser table we will store 'PersonId' & NOT 'PersonDetailID'

            //   AuthInfo authInfo = (ProfileDbContext.AuthInfoes.Where(a => a.Person.PersonGuid == personGuid && a.DomainId == DomainId)).FirstOrDefault();
            if (personDetails == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NoContent, new HttpError(ErrorInfo.UserNotFound)));
            }
            try
            {
                result = AnonymousDBContext.AssignProfileID(fpuserid, personDetails.PersonId);
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.Message, ex);
            }
            return(Request.CreateResponse(HttpStatusCode.OK, new
            {
                FPUserID = result
            }));
        }
        public HttpResponseMessage UpdateProfileId(long fpuserid, long fpprofileId)
        {
            if (!IsEnableAnonymous)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new
                {
                    FPUserID = 0
                }));
            }
            var result = 0;

            try
            {
                result = AnonymousDBContext.AssignProfileID(fpuserid, fpprofileId);
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.Message, ex);
            }
            return(Request.CreateResponse(HttpStatusCode.OK, new
            {
                FPUserID = result
            }));
        }