public ActionResult Create(OrganizationViewModel organization) { //OrganizationService os = new OrganizationService(); try { if (ModelState.IsValid) { organization o = new organization(); //o.id = organization.id; o.name = organization.name; o.type = organization.type; o.PresidentID = organization.PresidentID; o.Location = organization.Location; os.Add(o); os.Commit(); Session["organization"] = o; return(RedirectToAction("Index")); } return(View()); } catch { return(View()); } }
public ActionResult Delete(int id, FormCollection collection) { try { OrganizationService os = new OrganizationService(); organization o = os.GetById(id); OrganizationViewModel om = new OrganizationViewModel(); om.id = o.id; om.name = o.name; om.type = o.type; om.President = us.GetById((int)o.PresidentID); user i = om.President; o.PresidentID = null; i.DTYPE = "user"; us.Update(i); us.Commit(); os.Delete(o); os.Commit(); return(RedirectToAction("Index")); } catch { return(View()); } }