Пример #1
0
        /// <summary>
        /// Returns the user profile info from the EFS Service
        /// </summary>
        /// <param name="userAnid">
        /// Encrypted Anid of the user
        /// </param>
        /// <returns>
        /// UserInfo for the Anid
        /// </returns>
        public UserDemographics GetUserProfile(string userAnid)
        {
            Trace.WriteLine(string.Format("Received ProfileInfo request for Encrypted Anid : {0}", userAnid));
            UserDemographics userProfile = null;

            if (!string.IsNullOrEmpty(userAnid))
            {
                try
                {
                    userProfile = Proxy.GetUserProfile(userAnid);
                    Trace.WriteLine(string.Format("Finished Processing ProfileInfo request for Anid : {0}", userAnid));
                }
                catch (CryptographicException)
                {
                    throw new HttpResponseException(this.Request.CreateErrorResponse(HttpStatusCode.Unauthorized, "Invalid key...Unbale to decrypt the anid"));
                }
                catch (Exception exception)
                {
                    Trace.TraceError(exception.Message, exception);
                }
            }
            else
            {
                throw new HttpResponseException(this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Empty useranid passed"));
            }

            return(userProfile);
        }
Пример #2
0
        public ActionResult Create(UserDemographics obj)
        {
            using (RentMyWroxContext context = new RentMyWroxContext())
            {
                var ids = Request.Form.GetValues("HobbyIds");
                if (ids != null)
                {
                    obj.Hobbies = context.Hobbies.Where(x => ids.Contains(x.Id.ToString())).ToList();
                }
                context.UserDemographics.Add(obj);
                var validationErrors = context.GetValidationErrors();
                if (validationErrors.Count() == 0)
                {
                    context.SaveChanges();

                    ApplicationUser user = UserHelper.GetApplicationUser();
                    user.UserDemographicsId = obj.Id;
                    context.SaveChanges();

                    return(RedirectToAction("Index"));
                }
                ViewBag.ServerValidationErrors = ConvertValidationErrorsToString(validationErrors);
                return(View("Manage", obj));
            }
        }
Пример #3
0
        /// <summary>
        ///  Returns the user profile from the EFS service for the Anid
        /// </summary>
        /// <param name="userAnid">
        ///  Encrypted Anid
        /// </param>
        /// <returns>
        ///  User profile info for the Anid
        /// </returns>
        public static UserDemographics GetUserProfile(string userAnid)
        {
            UserDemographics userProfile   = null;
            string           decryptedAnid = Cipher.Decrypt(userAnid, AnidPassphrase);

            Trace.WriteLine(string.Format("Decrypted Anid : {0}", decryptedAnid));

            var client = new EfsService.UserInfoServiceClient();
            var lst    = new List <KeyValuePair <EfsService.UserIdType, string> >
            {
                new KeyValuePair <EfsService.UserIdType, string>(EfsService.UserIdType.Anid, decryptedAnid)
            };

            Trace.WriteLine(string.Format("Calling EFS Service to get Profile info for Anid : {0}", decryptedAnid));
            EfsService.UserDemographics result = client.GetDemographics(lst.ToArray());
            if (result != null)
            {
                Trace.WriteLine(string.Format("Successfully retrieved Profile info for Anid : {0}", decryptedAnid));
                userProfile = new UserDemographics {
                    Gender = result.Gender.ToString(), Age = result.Age
                };
                Trace.WriteLine("Constructed UserProfile Object");
                Trace.WriteLine(string.Format("Calling EFS Service to get opt out info for Anid : {0}", decryptedAnid));
                var  pref   = new EfsService.UserPreferenceServiceClient();
                bool?optout = pref.GetOptOutState(decryptedAnid, EfsService.UserIdType.Anid);
                userProfile.OptOut = optout.GetValueOrDefault(false);
            }
            else
            {
                Trace.WriteLine(string.Format("Profile not found fsor Anid : {0}", decryptedAnid));
            }

            return(userProfile);
        }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UserData"/> class.
 /// </summary>
 /// <param name="anid">The anid.</param>
 /// <param name="muid">The muid.</param>
 /// <param name="ip">The ip.</param>
 /// <param name="upanid">The upanid.</param>
 /// <param name="demographics">The user demographics</param>
 /// <param name="sessionId">The session id</param>
 public UserData(string anid = null, string muid = null, string ip = null, string upanid = null, UserDemographics demographics = null, Guid?sessionId = null)
 {
     Anid         = anid;
     Muid         = muid;
     Ip           = ip;
     Upanid       = upanid;
     Demographics = demographics;
     SessionId    = sessionId;
 }
Пример #5
0
        public ActionResult Create(UserDemographics obj)
        {
            try
            {
                // TODO: Add insert logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        // GET: UserDemographics/Edit/5
        public ActionResult Edit(int id)
        {
            var model = new UserDemographics
            {
                Gender            = "Male",
                Birthdate         = new DateTime(2000, id, id),
                MaritalStatus     = "Married",
                OwnHome           = true,
                TotalPeopleInHome = id,
                Hobbies           = new List <string> {
                    "Gardening", "Other"
                }
            };

            return(View("Manage", model));
        }
Пример #7
0
        // GET: UserDemographics/Edit/5
        public ActionResult Edit(int id)
        {
            //var model = new UserDemographics
            //{
            //    Gender = "Male",
            //    Birthdate = new DateTime(2000, id, id),
            //    MaritalStatus = "Married",
            //    OwnHome = true,
            //    TotalPeopleInHome = id,
            //    Hobbies = new List<string> { "Gardening", "Other" }
            //};
            //return View("Manage", model);

            var model = new UserDemographics();

            return(View("Manage", model));
        }
        public async Task <JsonResult> FaceAttribute(string data, bool flag)
        {
            try
            {
                UserDemographics ud = new UserDemographics();
                await ud.DetectFaceAttribute(data, flag);

                if (ud.Erorr == "")//converting all face's attribute as Json and returning the Json
                {
                    return(Json(new { Face = ud.Jarray, MaleCount = ud.MCount, FemaleCount = ud.FCount, Total = ud.MCount + ud.FCount }));
                }
                return(Json(new { Erorr = ud.Erorr }));
            }
            catch (Exception e)// handling runtime errors and returning error as Json
            {
                return(Json(new { Erorr = e.Message }));
            }
        }
 public ActionResult Create(UserDemographics obj)
 {
     try
     {
         using (RentMyWroxContext context = new RentMyWroxContext())
         {
             var ids = Request.Form.GetValues("HobbyIds");
             obj.Hobbies = context.Hobbies
                           .Where(x => ids.Contains(x.Id.ToString())).ToList();
             context.UserDemographics.Add(obj);
             context.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     catch
     {
         return(View());
     }
 }
Пример #10
0
 public PatientDetails(string hipCode, UserDemographics patient)
 {
     Code             = hipCode;
     UserDemographics = patient;
 }
        // GET: UserDemographics/Edit/5
        public ActionResult Edit(int id)
        {
            var model = new UserDemographics();

            return(View("Manage", model));
        }
Пример #12
0
 public PatientDetails(string code, UserDemographics userDemo)
 {
     Code             = code;
     UserDemographics = userDemo;
 }