public ActionResult DeleteConfirmed(long id) { #region "BTSS" string role; string user_name; try { role = Session["role"].ToString(); user_name = Session["logon_user"].ToString(); string grp_id = Session["grp_id"].ToString(); ViewBag.CanDelete = af.CanDelete(grp_id, "Manual Entries"); if (!ViewBag.CanDelete) { return(HttpNotFound()); } } catch (Exception exception) { string result = exception.Message.ToString(); return(HttpNotFound()); } #endregion "BTSS" #region "AddValues" OSC_ManualEntry oSC_ManualEntry = db.ManualEntries.Find(id); if (oSC_ManualEntry == null) { return(HttpNotFound()); } oSC_ManualEntry.DateUploaded = DateTime.Now; oSC_ManualEntry.UploadedBy = user_name; oSC_ManualEntry.IsActive = false; #endregion "AddValues" #region "Method" if (ModelState.IsValid) { db.Entry(oSC_ManualEntry).State = EntityState.Modified; db.SaveChanges(); } #endregion "Method" #region "Return" return(RedirectToAction("Index")); #endregion "Return" //old delete method //OSC_ManualEntry oSC_ManualEntry = db.ManualEntries.Find(id); //db.ManualEntries.Remove(oSC_ManualEntry); //db.SaveChanges(); //return RedirectToAction("Index"); }
// GET: ManualEntry/Edit/5 public ActionResult Edit(long?id) { #region "BTSS" string role; string user_name; try { role = Session["role"].ToString(); user_name = Session["logon_user"].ToString(); string grp_id = Session["grp_id"].ToString(); ViewBag.CanEdit = af.CanEdit(grp_id, "Manual Entries"); if (!ViewBag.CanEdit) { return(HttpNotFound()); } } catch (Exception exception) { string result = exception.Message.ToString(); return(HttpNotFound()); } #endregion "BTSS" #region "ViewBagProjectResponsibilities" ViewBag.ProjectResponsibilities = db.projectResponsibilities; #endregion "ViewBagProjectResponsibilities" #region "Method" if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } OSC_ManualEntry oSC_ManualEntry = db.ManualEntries.Find(id); if (oSC_ManualEntry == null) { return(HttpNotFound()); } if (!af.IsManaged(oSC_ManualEntry.TeamId, user_name, role)) { return(HttpNotFound()); } oSC_ManualEntry.Team = db.Teams.Find(oSC_ManualEntry.TeamId); oSC_ManualEntry.Representative = db.Representatives.Find(oSC_ManualEntry.RepId); oSC_ManualEntry.Representative.FullName = oSC_ManualEntry.Representative.FirstName + " " + oSC_ManualEntry.Representative.LastName; oSC_ManualEntry.PeriodCoverage = Convert.ToDateTime(oSC_ManualEntry.Month + "/1/" + oSC_ManualEntry.Year); #endregion "Method" #region "Return" return(View(oSC_ManualEntry)); #endregion "Return" }
public ActionResult Edit([Bind(Include = "EntryId,TeamId,RepId,GainLossOccurances,GainLossAmount,CallManagementScore,ProjectResponsibility,ScheduleAdherence,Compliance,ProductAccuracy,Commitment,JHValues,CallEfficiency,Engagement,AdministrativeProcedures,Month,Year,DateUploaded,UploadedBy,IsActive,ActiveProjects,CompletedProjects")] OSC_ManualEntry oSC_ManualEntry) { #region "BTSS" string role; string user_name; try { role = Session["role"].ToString(); user_name = Session["logon_user"].ToString(); string grp_id = Session["grp_id"].ToString(); ViewBag.CanEdit = af.CanEdit(grp_id, "Manual Entries"); if (!ViewBag.CanEdit) { return(HttpNotFound()); } } catch (Exception exception) { string result = exception.Message.ToString(); return(HttpNotFound()); } #endregion "BTSS" #region "AddValues" oSC_ManualEntry.Month = Convert.ToDateTime(oSC_ManualEntry.PeriodCoverage).Month; oSC_ManualEntry.Year = Convert.ToDateTime(oSC_ManualEntry.PeriodCoverage).Year; oSC_ManualEntry.DateUploaded = DateTime.Now; oSC_ManualEntry.UploadedBy = user_name; if (Session["role"].ToString() != "Admin") { oSC_ManualEntry.IsActive = true; } #endregion "AddValues" #region "Method" if (ModelState.IsValid) { db.Entry(oSC_ManualEntry).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } #endregion "Method" #region "Return" return(View(oSC_ManualEntry)); #endregion "Return" }