Ejemplo n.º 1
0
        public ActionResult Privacy()
        {
            Entities dbContext = new Entities();

            Guid userGuid = new Guid(UserHelper.getLoggedInUserId());

            UserPrivacy privacy = dbContext.UserPrivacies.SingleOrDefault(p => p.UserId == userGuid);

            if (privacy == null)
            {
                privacy = new UserPrivacy();
                privacy.SeeMyInfo = 0;
                privacy.SeeMyWall = 0;
                privacy.SeeMyPhotos = 0;
            }

            var model = new PrivacyModel {
                SeeMyInfo = privacy.SeeMyInfo,
                SeeMyWall = privacy.SeeMyWall,
                SeeMyPhotos = privacy.SeeMyPhotos
            };

            return View(model);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the UserPrivacies EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUserPrivacies(UserPrivacy userPrivacy)
 {
     base.AddObject("UserPrivacies", userPrivacy);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Create a new UserPrivacy object.
 /// </summary>
 /// <param name="userId">Initial value of the UserId property.</param>
 /// <param name="seeMyInfo">Initial value of the SeeMyInfo property.</param>
 /// <param name="seeMyWall">Initial value of the SeeMyWall property.</param>
 /// <param name="seeMyPhotos">Initial value of the SeeMyPhotos property.</param>
 public static UserPrivacy CreateUserPrivacy(global::System.Guid userId, global::System.Int32 seeMyInfo, global::System.Int32 seeMyWall, global::System.Int32 seeMyPhotos)
 {
     UserPrivacy userPrivacy = new UserPrivacy();
     userPrivacy.UserId = userId;
     userPrivacy.SeeMyInfo = seeMyInfo;
     userPrivacy.SeeMyWall = seeMyWall;
     userPrivacy.SeeMyPhotos = seeMyPhotos;
     return userPrivacy;
 }
Ejemplo n.º 4
0
        public ActionResult Privacy(PrivacyModel model)
        {
            ViewBag.message = null;

            if(ModelState.IsValid)
            {
                try
                {

                    Entities dbContext = new Entities();

                    Guid userGuid = new Guid(UserHelper.getLoggedInUserId());

                    UserPrivacy privacy = dbContext.UserPrivacies.SingleOrDefault(p => p.UserId == userGuid);

                    if (privacy == null)
                    {
                        privacy = new UserPrivacy();
                        privacy.UserId = userGuid;

                        privacy.SeeMyInfo = model.SeeMyInfo;
                        privacy.SeeMyWall = model.SeeMyWall;
                        privacy.SeeMyPhotos = model.SeeMyPhotos;
                        dbContext.UserPrivacies.AddObject(privacy);
                    }
                    else
                    {
                        privacy.SeeMyInfo = model.SeeMyInfo;
                        privacy.SeeMyWall = model.SeeMyWall;
                        privacy.SeeMyPhotos = model.SeeMyPhotos;
                    }

                    dbContext.SaveChanges();

                    ViewBag.message = "Your privacy settings were saved.";
                }catch(Exception ex)
                {
                    ModelState.AddModelError("", ex.Message);
                }
            }

            return View(model);
        }