public ActionResult Create(PollFormModel model) { if (ModelState.IsValid) { var item = Mapper.Map<PollFormModel, Poll>(model); // Object if (model.Object_id > 0) { item.Object = GetSession.Get<Poll>(model.Object_id); } else { item.Object = null; } // Anonymous User if (model.AnonymousUser_id > 0) { item.AnonymousUser = GetSession.Get<Employee>(model.AnonymousUser_id); } else { item.AnonymousUser = null; } GetSession.Save(item); return RedirectToAction("edit", new { id = item.Id }); } return View(model); }
public ActionResult Edit(PollFormModel model) { var item = GetSession.Get<Poll>(model.Id); //bool anonymous = model.Anonymous; //if (!model.Anonymous && item.Anonymous) //{ // if (item.PollItems.Any(pi => pi.EmployeePollItems.Count > 0)) // { // anonymous = true; // } //} if (ModelState.IsValid) { Mapper.Map<PollFormModel, Poll>(model, item); item.Anonymous = model.Anonymous; // Object if (model.Object_id > 0) { item.Object = GetSession.Get<Poll>(model.Object_id); } else { item.Object = null; } // Anonymous User if (model.AnonymousUser_id > 0) { item.AnonymousUser = GetSession.Get<Employee>(model.AnonymousUser_id); } else { item.AnonymousUser = null; } GetSession.Update(item); return RedirectToAction("Index"); } return View(model); }
public ActionResult Create() { var model = new PollFormModel(); model.InitMembers(GetSession); return View(model); }