public ActionResult Create(EmployeeMst employeeMst, HttpPostedFileBase file) { if (file == null) { ViewBag.ACT = "ERR"; ViewBag.Error = "Kindly Upload Image"; return(View()); } if (ModelState.IsValid) { if (file != null) { string path = Path.Combine(Server.MapPath("~/EmpImages"), Path.GetFileName(file.FileName)); file.SaveAs(path); employeeMst.Image = Path.GetFileName(file.FileName); } db.EmployeeMsts.Add(employeeMst); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(employeeMst)); }
public ActionResult DeleteConfirmed(int id) { EmployeeMst employeeMst = db.EmployeeMsts.Find(id); db.EmployeeMsts.Remove(employeeMst); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: EmployeeMsts/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EmployeeMst employeeMst = db.EmployeeMsts.Find(id); if (employeeMst == null) { return(HttpNotFound()); } return(View(employeeMst)); }
// GET: EmployeeMsts/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EmployeeMst employeeMst = db.EmployeeMsts.Find(id); employeeMst.Gender = employeeMst.Gender.Trim(); if (employeeMst == null) { return(HttpNotFound()); } return(View(employeeMst)); }