// GET: Contact public ActionResult Index(MemberContext mem) { var unitOfWork = new GenericRepository.UnitOfWork(mem); List <File> fileList = unitOfWork.Repository <MemberDatabase.File>().Query().Get().ToList(); return(View(fileList)); }
// GET: Contact public ActionResult Index(MemberContext mem) { var unitOfWork = new GenericRepository.UnitOfWork(mem); List <Group> groupList = unitOfWork.Repository <Group>().Query().Get().ToList(); int members = groupList[1].Members.Count(); return(View(groupList)); }
// GET: Document public ActionResult Index() { string connection = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; MemberContext mem = new MemberContext(connection); var unitOfWork = new GenericRepository.UnitOfWork(mem); // List<File> fileList = mem.myFiles.Where(f => f.FileType != "Photo").ToList(); List <File> fileList = unitOfWork.Repository <File>().Query().Get().ToList(); return(View("Documents", fileList)); }
public ActionResult View(int Id, MemberContext mem) { var unitOfWork = new GenericRepository.UnitOfWork(mem); MemberDatabase.Contact contact1 = unitOfWork.Repository <Contact>().FindById(Id); return(View(contact1)); }
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")); }
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)); }
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)); }
// GET: Contact public ActionResult Member(MemberContext mem) { //ContactList objContacts = new ContactList(); ////something feels redundant here //List<Models.Contact> _objContact = new List<Models.Contact>(); //_objContact = null; //GetContactList(); ////objContacts.ContactModel = _objContact; //string connection = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; //MemberContext mem = new MemberContext(connection); var unitOfWork = new GenericRepository.UnitOfWork(mem); List <Contact> contactList = unitOfWork.Repository <Contact>().Query().Get().ToList(); return(View(contactList)); }
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)); }
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)); }
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)); }