public ActionResult ChangeStatus(ArrangementStatus item) { if (ModelState.IsValid) { // guardar ArrangementStatus en la db // cambiar estado al Arrangement Arrangement arrangement = db.Arrangements.Find(item.ArrangementYear, item.ArrangementSerial); //DateTime date = DateTime.Parse(Request.Params["SessionDate"]); if (item.StatusEnum == StatusEnum.Status09) { arrangement.SessionDate = item.SessionDate; } if (item.StatusEnum == StatusEnum.Status10) { arrangement.Session = item.Session; } arrangement.Status = item.Status; item.Arrangement = arrangement; item.Date = DateTime.Now; item.CreatorId = User.Identity.Name; db.Statuses.Add(item); db.Configuration.ValidateOnSaveEnabled = false; db.SaveChanges(); db.Configuration.ValidateOnSaveEnabled = true; return RedirectToAction("Index"); } return View(item); }
public ActionResult Create(Arrangement item) { ArrangementStatus status; IQueryable<int> qry; if (!ModelState.IsValid) return View(item); qry = from x in db.Arrangements where x.Year == item.Year orderby x.Serial descending select x.Serial; item.Status = (int)StatusEnum.Status01; item.Year = DateTime.Today.Year; item.Serial = qry.FirstOrDefault() + 1; status = new ArrangementStatus { ArrangementYear = item.Year, ArrangementSerial = item.Serial, CreatorId = User.Identity.Name, Date = DateTime.Now, Status = item.Status, Comment = Mictlanix.Iam.Properties.Resources.NewStatusComment }; db.Arrangements.Add(item); db.Statuses.Add(status); db.SaveChanges(); return RedirectToAction("Index"); }