public ActionResult Create([Bind(Include = "id,username,name,password,address,email")] taikhoan taikhoan) { if (ModelState.IsValid) { db.taikhoans.Add(taikhoan); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(taikhoan)); }
public ActionResult Create([Bind(Include = "id,name,loai")] loaithutuc loaithutuc) { if (ModelState.IsValid) { db.loaithutucs.Add(loaithutuc); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(loaithutuc)); }
public ActionResult Save(Employe emp) { bool status = false; if (ModelState.IsValid) { using (DBmodels dm = new DBmodels()) { if (emp.EmployeID > 0) { var v = dm.Employes.Where(a => a.EmployeID == emp.EmployeID).FirstOrDefault(); if (v != null) { //edit v.Name = emp.Name; v.Office = emp.Office; v.Position = emp.Position; v.Age = emp.Age; v.Salary = emp.Salary; } } else { dm.Employes.Add(emp); } dm.SaveChanges(); status = true; } } return(Json(new { status = status })); }
public ActionResult DeleteEmplyee(int id) { bool status = false; using (DBmodels dm = new DBmodels()) { var v = dm.Employes.Where(a => a.EmployeID == id).FirstOrDefault(); if (v != null) { dm.Employes.Remove(v); dm.SaveChanges(); status = true; } } return(Json(new { status = status })); }
public ActionResult CreateOrEditUser(User user) { using (DBmodels db = new DBmodels()) { if (db.Users.Any(x => user.UserName == x.UserName)) { ViewBag.DuplicateMessage = "User Name '" + user.UserName + "' already exists"; return(View("CreateOrEditUser", user)); } else { db.Users.Add(user); db.SaveChanges(); } } ViewBag.successmessage = "Successfully '" + user.UserName + "' added to the portal"; ModelState.Clear(); return(View("CreateOrEditUser", new User())); }
public ActionResult Create([Bind(Include = "id,name,nguoitao,nguoiduyet")] thutuc thutuc) { if (ModelState.IsValid) { db.thutucs.Add(thutuc); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(thutuc)); }