Exemplo n.º 1
0
        public virtual ActionResult Delete(int id)
        {
            string        connection = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
            MemberContext mem        = new MemberContext(connection);
            var           unitOfWork = new GenericRepository.UnitOfWork(mem);

            unitOfWork.Repository <File>().Delete(id);
            unitOfWork.Save();


            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
0
        public ActionResult Add(MemberDatabase.Group myGroup)
        {
            string connection = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;

            MemberContext mem = new MemberContext(connection);

            var unitOfWork = new GenericRepository.UnitOfWork(mem);

            unitOfWork.Repository <MemberDatabase.Group>().Insert(myGroup);


            unitOfWork.Save();
            List <Group> groupList = unitOfWork.Repository <Group>().Query().Get().ToList();


            return(View("Index", groupList));
        }
Exemplo n.º 4
0
        public ActionResult UploadPhoto(HttpPostedFileBase file, MemberContext mem)
        {
            string serverPath = "";
            string filePath   = "";

            if (file != null && file.ContentLength > 0)
            {
                try
                {
                    //useful, but actually not used here. I eventually figured out changing permissions on the folder
                    //this returned mfreedm
                    string user = HttpContext.User.Identity.Name;

                    serverPath = "/Platform/Images/" + file.FileName;
                    filePath   = Server.MapPath(serverPath);
                    file.SaveAs(filePath);
                    ViewBag.Message = "File uploaded successfully";
                }
                catch (Exception ex)
                {
                    ViewBag.Message = "ERROR:" + ex.Message.ToString();
                }
            }
            else
            {
                ViewBag.Message = "You have not specified a file.";
            }

            var unitOfWork = new GenericRepository.UnitOfWork(mem);

            MemberDatabase.File photo = new MemberDatabase.File();

            photo.FilePath    = serverPath;
            photo.FileType    = "Photo";
            photo.UploadDate  = DateTime.Now;
            photo.Description = "uploaded document";

            unitOfWork.Repository <MemberDatabase.File>().Insert(photo);
            unitOfWork.Save();


            List <File> fileList = unitOfWork.Repository <MemberDatabase.File>().Query().Get().ToList();

            return(View("Index", fileList));
        }
Exemplo n.º 5
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));
        }
Exemplo n.º 6
0
        public ActionResult UploadDocument(HttpPostedFileBase file)
        {
            string        connection = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
            MemberContext mem        = new MemberContext(connection);
            var           unitOfWork = new GenericRepository.UnitOfWork(mem);

            if (file != null && file.ContentLength > 0)
            {
                string path = "C:\\Users\\mfreedm\\Documents\\Visual Studio 2015\\Projects\\Platform\\Platform\\Temp";
                try
                {
                    file.SaveAs(path);
                    ViewBag.Message = "File uploaded successfully";
                }
                catch (Exception ex)
                {
                    ViewBag.Message = "ERROR:" + ex.Message.ToString();
                }


                MemberDatabase.File newFile = new MemberDatabase.File();

                newFile.FilePath    = path;
                newFile.Description = "File Uploaded";

                unitOfWork.Repository <File>().Insert(newFile);
                unitOfWork.Save();
            }
            else
            {
                ViewBag.Message = "You have not specified a file.";
            }

            List <File> fileList = unitOfWork.Repository <File>().Query().Get().ToList();

            //problems with losing viewbag after using redirectToaction
            return(View("Documents", fileList));
        }