public ActionResult Delete(int id) { var person = (from x in context.Person where x.PersonId == id select x); context.Person.Remove(person.FirstOrDefault()); context.SaveChanges(); int personId = GlobalVariable.GetCompanyId(); if (GlobalVariable.GetclickStatus()) { personId = -1; } return(RedirectToAction("List", new { companyid = personId })); }
public ActionResult Create() { CreateViewBag(); int id = GlobalVariable.GetCompanyId(); Person person = new Person(); if (id > 0) { ViewBag.message = true; person.CompanyId = id; person.CompanyName = (from x in context.Company where x.CompanyId == id select x.Name).FirstOrDefault(); return(View(person)); } else { ViewBag.message = false; // person.CompanyId = 0; return(View(person)); } }