Beispiel #1
0
        public ActionResult Create(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                Models.Address newAddress = new Models.Address()
                {
                    person_id  = id,
                    city       = collection["city"],
                    desc       = collection["desc"],
                    state      = collection["state"],
                    street     = collection["street"],
                    zip_code   = collection["zip_code"],
                    country_id = Int32.Parse(collection["country_id"])
                };

                db.Addresses.Add(newAddress);
                db.SaveChanges();

                return(RedirectToAction("Index", new { id = id }));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #2
0
        public ActionResult Edit(FormCollection collection)
        {
            try
            { if (Session["person_id"] != null)
              {
                  int         currentUser = int.Parse(Session["user_id"].ToString());
                  Models.User theUser     = db.Users.SingleOrDefault(p => p.user_id == currentUser);

                  // TODO: Add update logic here
                  if (collection["Confirm"].Equals(collection["password_hash"]))
                  {
                      theUser.password_hash = Crypto.HashPassword(collection["password_hash"]);

                      db.SaveChanges();

                      return(RedirectToAction("AllUsers", "Friend"));
                  }
                  else
                  {
                      ViewBag.error = "The passwords does not match.";
                      return(View());
                  }
              }
              else
              {
                  return(RedirectToAction("Index"));
              } }
            catch
            {
                return(View());
            }
        }
        // GET: Message/Create
        public ActionResult Create(int id)
        {
            int counter = 0;

            ViewBag.id = id;
            int user           = Int32.Parse(Session["person_id"].ToString());
            int counterMessage = Int32.Parse(Session["new_message"].ToString());
            IEnumerable <Models.Message> theMessage = db.Messages.Where(p => p.receiver == user && p.sender == id);

            foreach (var item in theMessage)
            {
                if (item.read == "Not read")
                {
                    counter++;
                }
                item.read = "Read";
            }

            counterMessage        -= counter;
            Session["new_message"] = counterMessage;
            db.SaveChanges();

            ViewBag.message = db.Messages.Where(p => p.receiver == user || p.sender == user);

            return(View());
        }
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here
                int            id        = Int32.Parse(Session["user_id"].ToString());
                Models.Profile newClient = new Models.Profile();
                Models.User    theUser   = db.Users.SingleOrDefault(p => p.user_id == id);

                newClient.first_name   = collection["first_name"];
                newClient.last_name    = collection["last_name"];
                newClient.notes        = collection["notes"];
                newClient.gender       = collection["gender"];
                newClient.profile_pic  = "default.jpg";
                newClient.privacy_flag = "Off";


                db.Profiles.Add(newClient);
                theUser.person_id = newClient.person_id;

                db.SaveChanges();

                Models.Profile theProf = db.Profiles.SingleOrDefault(p => p.person_id == theUser.person_id);

                Session["person_id"] = theProf.person_id;

                return(View("Index", newClient));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #5
0
        public ActionResult Approve(int id)
        {
            int personId = Int32.Parse(Session["person_id"].ToString());

            Models.FriendLink theLink = db.FriendLinks.SingleOrDefault(c => c.requester == id && c.requested == personId);

            theLink.approved = "true";
            theLink.status   = "Friends";

            db.SaveChanges();

            return(View("FriendLink", db.FriendLinks));
        }
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here
                Models.Client newClient = new Models.Client()
                {
                    first_name = collection["first_name"],
                    last_name  = collection["last_name"]
                };

                database.Clients.Add(newClient);
                database.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        // GET: Picture
        public ActionResult Index(int id)
        {
            ViewBag.id = id;

            Models.Profile theClient = db.Profiles.SingleOrDefault(c => c.person_id == id);

            int personId = Int32.Parse(Session["person_id"].ToString());

            if (id == personId)
            {
                int counter = 0;

                int counterLike = Int32.Parse(Session["new_Likes"].ToString());

                IEnumerable <Models.Picture> yourPics = db.Pictures.Where(c => c.person_id == personId);

                foreach (Models.Like ML in db.Likes.ToList())
                {
                    if (yourPics.Contains(db.Pictures.SingleOrDefault(c => c.picture_id == ML.picture_id)))
                    {
                        if (ML.read == "Not read")
                        {
                            counter++;
                        }
                        ML.read = "Read";
                    }
                }
                db.SaveChanges();
                counterLike         -= counter;
                Session["new_Likes"] = counterLike;
            }
            return(View(theClient));
        }
        // GET: Comment
        public ActionResult Index(int id)
        {
            ViewBag.id = id;

            int personId = Int32.Parse(Session["person_id"].ToString());

            Models.Picture thePicutre = db.Pictures.SingleOrDefault(c => c.picture_id == id);
            int            counter    = 0;

            int counterCommentLike = Int32.Parse(Session["new_CommentLikes"].ToString());

            IEnumerable <Models.Comment> yourComment = db.Comments.Where(c => c.person_id == personId);

            foreach (Models.Comment_like ML in db.Comment_like.ToList())
            {
                if (yourComment.Contains(db.Comments.SingleOrDefault(c => c.comment_id == ML.comment_id)) && ML.read.Equals("Not read"))
                {
                    counter++;
                    ML.read = "Read";
                }
            }
            db.SaveChanges();
            counterCommentLike         -= counter;
            Session["new_CommentLikes"] = counterCommentLike;

            return(View(thePicutre));
        }
        public ActionResult Create(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here
                Models.Contact newContact = new Models.Contact()
                {
                    person_id = id,
                    type_info = collection["type_info"],
                    info      = collection["info"]
                };

                db.Contacts.Add(newContact);
                db.SaveChanges();

                return(RedirectToAction("Index", new { id = id }));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #10
0
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            Models.ClientEntities db = new Models.ClientEntities();

            int personId = Int32.Parse(filterContext.HttpContext.Session["person_id"].ToString());

            foreach (Models.FriendLink MF in db.FriendLinks.ToList())
            {
                if (MF.requested == personId && MF.read.Equals("Not read"))
                {
                    MF.read = "Read";
                    db.SaveChanges();
                }
            }
        }