private ActionResult InternalSaveStatus(UnitStatus status, FormCollection fields) { TryUpdateModel(status, new string[] { "StatusName", "IsActive", "WacLevel", "GetsAccount" }); //Guid unitId = new Guid(fields["Unit"]); //SarUnit unit = (from u in this.db.Units where u.Id == unitId select u).First(); //um.Unit = unit; //Guid statusId = new Guid(fields["Status"]); //UnitStatus status = (from s in this.db.SarUnitStatusTypes where s.Id == statusId select s).First(); //um.Status = status; //Guid personId = new Guid(fields["Person"]); //Member person = (from m in this.db.Members where m.Id == personId select m).First(); //um.Status = status; if (!ModelState.IsValid) { return InternalEditStatus(status); } this.db.SaveChanges(); return RedirectToAction("ClosePopup"); }
public ActionResult CreateStatus(Guid unitId, FormCollection fields) { if (Session["NewStatusGuid"] != null && Session["NewStatusGuid"].ToString() != fields["NewStatusGuid"]) { throw new InvalidOperationException("Invalid operation. Are you trying to re-create a status?"); } Session.Remove("NewStatusGuid"); SarUnit unit = (from u in this.db.Units where u.Id == unitId select u).FirstOrDefault(); ViewData["Title"] = "New Unit Status for " + unit.DisplayName; UnitStatus status = new UnitStatus(); status.Unit = unit; this.db.UnitStatusTypes.Add(status); return InternalSaveStatus(status, fields); }
private ActionResult InternalEditStatus(UnitStatus s) { List<WacLevel> values = new List<WacLevel>(); foreach (object o in Enum.GetValues(typeof(WacLevel))) { values.Add((WacLevel)o); } ViewData["HideFrame"] = true; ViewData["WacLevel"] = new SelectList((from wl in values.Reverse<WacLevel>() select new { Name = wl.ToString(), Value = wl }), "Name", "Value", s.WacLevel); return View("EditStatus", s); }
public ActionResult CreateStatus(Guid unitId) { SarUnit unit = (from u in this.db.Units where u.Id == unitId select u).FirstOrDefault(); ViewData["Title"] = "New Unit Status for " + unit.DisplayName; UnitStatus status = new UnitStatus() { Unit = unit }; Session.Add("NewStatusGuid", status.Id); ViewData["NewStatusGuid"] = Session["NewStatusGuid"]; return InternalEditStatus(status); }