Example #1
0
        public ActionResult register(Member member)
        {
            if (ModelState.IsValid)
            {
                //if (member.email_address != null)
                //{
                user = Context.Members.FirstOrDefault(x => x.email_address == member.email_address);

                if (user == null)
                {
                    Context.Members.Add(member);
                    member.date_joined = DateTime.Now;
                    Context.SaveChanges();
                    TempData["ID"]  = member.member_id;
                    user            = Context.Members.FirstOrDefault(x => x.email_address == member.email_address);
                    Session["user"] = user;
                    return(RedirectToAction("Address"));
                }
                else
                {
                    TempData["RegisterMsg"] = "Email Address Already Exist";
                }
                //}
            }

            return(View("welcome", member));
        }
Example #2
0
 public ActionResult Edit(Member member, Address address, HttpPostedFileBase profile_image)
 {
     if (ModelState.IsValid)
     {
         if (profile_image != null)
         {
             profile_image.SaveAs(Server.MapPath("~/LayoutResources/images/" + profile_image.FileName));
             member.profile_image = ("/LayoutResources/images/" + profile_image.FileName) as string;
         }
         else
         {
             member.profile_image = Session["user_profile_image"] as string;
             //member.profile_image = ("/LayoutResources/images/user.png") as string;
         }
         Context.Entry(member).State = System.Data.Entity.EntityState.Modified;
         Address add = Session["Address"] as Address;
         address.Address_id           = add.Address_id;
         address.member_id            = add.member_id;
         Context.Entry(address).State = System.Data.Entity.EntityState.Modified;
         Context.SaveChanges();
         Session["user"] = member;
         return(PartialView(member));
     }
     else
     {
         return(PartialView(member));
     }
 }
Example #3
0
        public ActionResult connect(int id) // الراجل اللي باعت id  //تمام و زي الفل
        {
            var        user = Session["user"] as Member;
            Connection con  = new Connection()
            {
                connection_member_id = id,
                member_id            = user.member_id,
                date_connection_made = DateTime.Now
            };

            ViewBag.friend = id;
            db.Connections.Add(con);
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Example #4
0
        public ActionResult Delete(int id)
        {
            Member     member     = Context.Members.FirstOrDefault(m => m.member_id == id);
            Address    address    = Context.Addresses.FirstOrDefault(a => a.member_id == member.member_id);
            Experience experience = Context.Experiences.FirstOrDefault(a => a.member_id == member.member_id);
            Education  education  = Context.Educations.FirstOrDefault(a => a.member_id == member.member_id);

            Context.Entry(member).State = System.Data.Entity.EntityState.Deleted;
            if (address != null)
            {
                Context.Entry(address).State = System.Data.Entity.EntityState.Deleted;
            }
            if (experience != null)
            {
                Context.Entry(experience).State = System.Data.Entity.EntityState.Deleted;
            }
            if (education != null)
            {
                Context.Entry(education).State = System.Data.Entity.EntityState.Deleted;
            }
            Context.SaveChanges();
            List <Member> members = (from m in Context.Members
                                     select m).ToList();

            return(View("index", members));
        }
Example #5
0
 public ActionResult CreatePost(Post post, HttpPostedFileBase post_image)
 {
     if (ModelState.IsValid)
     {
         if (post_image != null)
         {
             post_image.SaveAs(Server.MapPath("~/LayoutResources/images/posts/" + post_image.FileName));
             post.post_image = ("/LayoutResources/images/posts/" + post_image.FileName) as string;
         }
         user = Session["user"] as Member;
         Random rnd = new Random();
         post.member_id            = user.member_id;
         post.post_id              = rnd.Next(1, 1000);
         Context.Entry(post).State = System.Data.Entity.EntityState.Added;
         Context.SaveChanges();
     }
     return(RedirectToAction("GetAll"));
 }