public ActionResult CompanyEdit(dt_company com) { if (ModelState.IsValid) { if (db.dt_company.Where(a => a.companyname == com.companyname && a.ID != com.ID).FirstOrDefault() == null) { var company = db.dt_company.Where(a => a.ID == com.ID).FirstOrDefault(); company.parentID = com.parentID; company.productArea = com.productArea; company.tel = com.tel; company.date = com.date; company.companyname = com.companyname; company.adress = com.adress; db.SaveChanges(); TempData["message"] = "1"; } else { TempData["message"] = "0"; } } SirketGoster(com.ID, com.parentID); return View(com); }
public ActionResult CompanyCreate(dt_company company) { if (ModelState.IsValid) { var user = db.dt_company.Where(a => a.companyname == company.companyname).FirstOrDefault(); if (user == null) { db.dt_company.AddObject(new dt_company { companyname = company.companyname, active = 1, adress = company.adress, tel = company.tel, productArea = company.productArea, parentID = company.parentID, date = company.date }); db.SaveChanges(); TempData["message"] = "1"; } else { TempData["message"] = "0"; } } SirketGoster(); return View(company); }