Пример #1
0
        public ActionResult Edit(int Id)
        {
            MemberDatabase.Repo.ContactRepository repo = new MemberDatabase.Repo.ContactRepository();

            MemberDatabase.Contact contact1 = repo.FindById(Id);



            return(View(contact1));
        }
Пример #2
0
        public ActionResult View(int Id, MemberContext mem)
        {
            var unitOfWork = new GenericRepository.UnitOfWork(mem);


            MemberDatabase.Contact contact1 = unitOfWork.Repository <Contact>().FindById(Id);



            return(View(contact1));
        }
Пример #3
0
        public ActionResult Add(MemberDatabase.Contact myContact, MemberContext mem)
        {
            //    string connection = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;

            //    MemberContext mem = new MemberContext(connection);
            var unitOfWork = new GenericRepository.UnitOfWork(mem);

            unitOfWork.Repository <Contact>().InsertGraph(myContact);

            unitOfWork.Save();
            List <Contact> memList = unitOfWork.Repository <Contact>().Query().Get().ToList();


            return(View("Index", memList));
        }
Пример #4
0
        public ActionResult Update(MemberDatabase.Contact myContact, MemberContext mem)
        {
            //string connection = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
            //MemberContext mem = new MemberContext(connection);
            var unitOfWork = new GenericRepository.UnitOfWork(mem);

            unitOfWork.Repository <Contact>().Update(myContact);

            //  mem.Entry(myContact).Property(m => m.Username).IsModified = true;
            //mem.Entry(myContact).Property(m => m.FirstName).IsModified = true;
            //mem.Entry(myContact).Property(m => m.LastName).IsModified = true;
            //mem.Entry(myContact).Property(m => m.Email).IsModified = true;

            unitOfWork.Save();
            List <Contact> memList = unitOfWork.Repository <Contact>().Query().Get().ToList();


            return(View("Index", memList));
        }
Пример #5
0
        public ActionResult Comment(MemberDatabase.Contact myContact, MemberContext mem)
        {
            MemberDatabase.Comment com = new Comment();
            com.comment   = "new comment";
            com.ContactId = myContact.Id;
            com.postDate  = DateTime.Now;
            com.postedBy  = "mfreedm";

            mem.DbSet <Comment>().Add(com);
            mem.SaveChanges();

            MemberDatabase.Repo.ContactRepository repo = new MemberDatabase.Repo.ContactRepository();

            MemberDatabase.Contact contact1 = repo.FindById(myContact.Id);



            return(View("Edit", contact1));
        }