Esempio n. 1
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));
        }
Esempio n. 2
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"));
 }
Esempio n. 3
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));
     }
 }
Esempio n. 4
0
        public ActionResult Address(/*[Bind(Include = "Address_id,line_1,line_2,line_3,city,state_country_province,zip_or_postcode,country,other_details")]*/ Address address)
        {
            //int mID = Convert.ToInt32(TempData["ID"]);
            Member member = Session["user"] as Member;

            if (ModelState.IsValid)
            {
                address.member_id            = member.member_id;
                Context.Entry(address).State = System.Data.Entity.EntityState.Added;
                Context.SaveChanges();
                Session["Address"] = address;
                return(RedirectToAction("personalInfo"));
            }
            return(View(address));
        }