public ActionResult Edit(int primaryKey1, int primaryKey2, Comm comm) { // if Check current user is Committees Super Admin first // If (isCSA is true) if (ModelState.IsValid) { db.Entry(comm).State = EntityState.Modified; db.SaveChanges(); AuditLogController.Add("Edit", User.Identity.Name, "Edited committee: " + comm.Name); return(RedirectToAction("details", new { primaryKey1 = comm.CommOwn_ID, primaryKey2 = comm.ID })); } return(View(comm)); }
public ActionResult Edit(int primaryKey1, int primaryKey2, CommMember commmember) { //Set Variables commmember.Comm_CommOwn_ID = primaryKey1; commmember.Comm_ID = primaryKey2; commmember.LastAssignedBy = User.Identity.Name; commmember.LastAssignedDate = DateTime.Now; commmember.EndDate = commmember.EndDate.Date; switch (commmember.MemberRole_Role) { case "Chair": commmember.IsAdministrator = "Y"; commmember.IsConvener = "N"; break; case "Co-chair": commmember.IsAdministrator = "Y"; commmember.IsConvener = "N"; break; case "Convener": commmember.IsConvener = "Y"; commmember.IsAdministrator = "N"; break; case "Member": commmember.IsAdministrator = "N"; commmember.IsConvener = "N"; break; } if (ModelState.IsValid) { db.Entry(commmember).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Details", "Committees", new { primaryKey1 = primaryKey1, primaryKey2 = primaryKey2 })); } Comm comm = db.Comm.Find(primaryKey1, primaryKey2); ViewBag.CommName = comm.Name; ViewBag.MemberRoles = new SelectList(db.MemberRole, "Role", "Role", commmember.MemberRole_Role); return(View(commmember)); }
public ActionResult Edit(CommSuperAdmin commsuperadmin) { if (ModelState.IsValid) { db.Entry(commsuperadmin).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "Divisions", new { primaryKey1 = commsuperadmin.CommOwn_ID })); } return(View(commsuperadmin)); }
public ActionResult Edit(Meeting meeting) { //TODO: check permissions //if updated data is valid save and redirect to meeting parent committee if (ModelState.IsValid) { db.Entry(meeting).State = EntityState.Modified; db.SaveChanges(); AuditLogController.Add("Edit", User.Identity.Name, "Edited Meeting: " + meeting.Comm_CommOwn_ID + "/" + meeting.Comm_ID + "/" + meeting.DateTime.ToString("MM-dd-yyyy h.mm.ss t\\M")); return(RedirectToAction("Details", "Meetings", new { primaryKey1 = meeting.Comm_CommOwn_ID, primaryKey2 = meeting.Comm_ID, primaryKey3 = meeting.DateTime.ToString("MM-dd-yyyy h.mm.ss t\\M") })); } //otherwise return to editing meeting return(View(meeting)); }
public ActionResult Edit(DiscItem discitem, String isCommDocument, String comDocTitle, String category, string[] voteTypes) { HttpPostedFileBase file = Request.Files[0]; int oldFileLength = (int)Session["fileLength"]; byte[] oldFileImage = new byte[oldFileLength]; oldFileImage = (byte[])Session["fileImage"]; if (file.ContentLength > 0) // checks if file was uploaded to the form, maked it the new document { // getting size of file int fileLen = file.ContentLength; // create write buffer byte[] byteFile = new byte[fileLen]; file.InputStream.Read(byteFile, 0, fileLen); // write file to discItemDoc discitem.DiscItemDocument.FileImage = byteFile; discitem.DiscItemDocument.Filename = file.FileName; discitem.DiscItemDocument.ContentType = file.ContentType; discitem.DiscItemDocument.DiscItem_Title = discitem.Title; discitem.DiscItemDocument.DiscItem_Meeting_Comm_CommOwn_ID = discitem.Meeting_Comm_CommOwn_ID; discitem.DiscItemDocument.DiscItem_Meeting_Comm_ID = discitem.Meeting_Comm_ID; discitem.DiscItemDocument.DiscItem_Meeting_DateTime = discitem.Meeting_DateTime; } else if (oldFileImage != null && oldFileImage.Length > 0) // keeps old document { //discitem.DiscItemDocument.Filename = file.FileName; discitem.DiscItemDocument.FileImage = (byte[])Session["fileImage"]; discitem.DiscItemDocument.ContentType = (string)Session["contentType"]; discitem.DiscItemDocument.DiscItem_Title = discitem.Title; discitem.DiscItemDocument.DiscItem_Meeting_Comm_CommOwn_ID = discitem.Meeting_Comm_CommOwn_ID; discitem.DiscItemDocument.DiscItem_Meeting_Comm_ID = discitem.Meeting_Comm_ID; discitem.DiscItemDocument.DiscItem_Meeting_DateTime = discitem.Meeting_DateTime; } else // there was and still is no document for this discussion { discitem.DiscItemDocument = null; } CommDocument commDoc = new CommDocument(); bool commDocumentAdded = false; // clears out the sessions, data in session no loner needed Session["fileImage"] = null; Session["contentType"] = null; Session["fileLength"] = null; if (isCommDocument != "N") { commDoc.Comm_CommOwn_ID = discitem.Meeting_Comm_CommOwn_ID; commDoc.Comm_ID = discitem.Meeting_Comm_ID; commDoc.Title = comDocTitle; commDoc.DisplayDate = DateTime.Now; commDoc.Tags = discitem.DiscItemDocument.Tags; commDoc.Filename = discitem.DiscItemDocument.Filename; commDoc.FileImage = discitem.DiscItemDocument.FileImage; commDoc.UploadedBy = User.Identity.Name; commDoc.UploadedDate = DateTime.Now; commDoc.IsArchived = "N"; commDoc.ArchivedBy = null; commDoc.ArchivedDate = null; commDoc.ContentType = discitem.DiscItemDocument.ContentType; if (db.CommDocument.Find(discitem.Meeting_Comm_CommOwn_ID, discitem.Meeting_Comm_ID, comDocTitle) != null) { ModelState.AddModelError("docTitle", "A committee document already exists with that title."); ViewBag.Title = new SelectList(db.DiscItem, "Title", discitem.Title); ViewBag.Meeting_Comm_CommOwn_ID = new SelectList(db.Meeting, "Comm_CommOwn_ID", "Location", discitem.Meeting_Comm_CommOwn_ID); ViewBag.CreatedBy = new SelectList(db.SysUser, "Email", "FirstName", discitem.CreatedBy); ViewBag.Category = new SelectList(db.Category, "Type", "Description"); Session["fileImage"] = discitem.DiscItemDocument.FileImage; Session["contentType"] = discitem.DiscItemDocument.ContentType; Session["fileLength"] = discitem.DiscItemDocument.FileImage.Length; return(View(discitem)); } if (category == "") { ModelState.AddModelError("Category", "Select a category"); ViewBag.Title = new SelectList(db.DiscItem, "Title", discitem.Title); ViewBag.Meeting_Comm_CommOwn_ID = new SelectList(db.Meeting, "Comm_CommOwn_ID", "Location", discitem.Meeting_Comm_CommOwn_ID); ViewBag.CreatedBy = new SelectList(db.SysUser, "Email", "FirstName", discitem.CreatedBy); ViewBag.Category = new SelectList(db.Category, "Type", "Description"); Session["fileImage"] = discitem.DiscItemDocument.FileImage; Session["contentType"] = discitem.DiscItemDocument.ContentType; Session["fileLength"] = discitem.DiscItemDocument.FileImage.Length; return(View(discitem)); } commDoc.Category = category; commDocumentAdded = true; if (isCommDocument == "Ypub") { commDoc.IsPublic = "Y"; commDoc.IsProtected = "N"; } else { commDoc.IsPublic = "N"; commDoc.IsProtected = "Y"; } } // for testing, this need to be true and it is not bool lookAtModelStateValid = ModelState.IsValid; //if (ModelState.IsValid) //{ db.Entry(discitem).State = EntityState.Modified; if (discitem.DiscItemDocument != null) { if (oldFileImage == null) { db.DiscItemDocument.Add(discitem.DiscItemDocument); } else { db.Entry(discitem.DiscItemDocument).State = EntityState.Modified; } } if (commDocumentAdded) { db.CommDocument.Add(commDoc); } db.SaveChanges(); return(RedirectToAction("Details", "DiscItem", new { primaryKey1 = discitem.Meeting_Comm_CommOwn_ID, primaryKey2 = discitem.Meeting_Comm_ID, primaryKey3 = discitem.Meeting_DateTime.ToString("MM-dd-yyyy h.mm.ss t\\M"), primaryKey4 = discitem.Title })); //} //ViewBag.Title = new SelectList(db.DiscItemDocument, "DiscItem_Meeting_Comm_CommOwn_ID", "Filename", discitem.Title); //ViewBag.Meeting_Comm_CommOwn_ID = new SelectList(db.Meeting, "Comm_CommOwn_ID", "Location", discitem.Meeting_Comm_CommOwn_ID); //ViewBag.CreatedBy = new SelectList(db.SysUser, "Email", "FirstName", discitem.CreatedBy); //ViewBag.Category = new SelectList(db.Category, "Type", "Description"); //Session["fileImage"] = discitem.DiscItemDocument.FileImage; //Session["contentType"] = discitem.DiscItemDocument.ContentType; //return View(discitem); }
public ActionResult Edit(CommDocument commdocument) { HttpPostedFileBase file = Request.Files["myFile"]; if ((string)Session["isPublic"] == "Y" && commdocument.IsPublic == "N") { ModelState.AddModelError("IsPublic", "Can not make a public document protected"); ViewBag.Category = new SelectList(db.Category, "Type", "Description", commdocument.Category); return(View(commdocument)); } switch (commdocument.IsPublic) { case "N": commdocument.IsPublic = "N"; commdocument.IsProtected = "Y"; commdocument.IsArchived = "N"; break; case "A": commdocument.IsPublic = "N"; commdocument.IsProtected = "N"; commdocument.IsArchived = "Y"; break; case "Y": commdocument.IsPublic = "Y"; commdocument.IsProtected = "N"; commdocument.IsArchived = "N"; break; } if (file.ContentLength > 0) // checks if file was uploaded to the form { // getting size of file int fileLen = file.ContentLength; // create write buffer byte[] byteFile = new byte[fileLen]; file.InputStream.Read(byteFile, 0, fileLen); // write file to commdocument, replacing old file commdocument.FileImage = byteFile; commdocument.Filename = file.FileName; commdocument.ContentType = file.ContentType; } else { // put old document back and leave unchanged commdocument.FileImage = (byte[])Session["fileImage"]; commdocument.ContentType = (string)Session["contentType"]; } // clears out session data, no longer needed Session["fileImage"] = null; Session["contentType"] = null; Session["isPublic"] = null; // sets who archived and archive time, if document is flagged for archive by user if (commdocument.IsArchived == "Y") { commdocument.ArchivedBy = User.Identity.Name; commdocument.ArchivedDate = DateTime.Now; } if (ModelState.IsValid) { db.Entry(commdocument).State = EntityState.Modified; db.SaveChanges(); AuditLogController.Add("Committee Document Edit", User.Identity.Name, "Committee Document: " + commdocument.Title + " in committee " + commdocument.Comm_CommOwn_ID + " - " + commdocument.Comm_ID + "was edited"); return(RedirectToAction("Details", "Committees", new { primaryKey1 = commdocument.Comm_CommOwn_ID, primaryKey2 = commdocument.Comm_ID })); } // something went wrong, return to edit page ViewBag.Category = new SelectList(db.Category, "Type", "Description", commdocument.Category); return(View(commdocument)); }