public ActionResult Create(UniversityEmployee universityEmployee, HttpPostedFileBase filelist) { byte[] data = null; data = new byte[filelist.ContentLength]; filelist.InputStream.Read(data, 0, filelist.ContentLength); if (ModelState.IsValid) { employee emp = new employee(); Guid re = new Guid(); Random R = new Random(); var userName = User.Identity.GetUserName(); var userId = User.Identity.GetUserId(); universityEmployee.UserPhoto = data; emp.EmpID = re.ToString() + R.Next(1, 100).ToString(); universityEmployee.EmpUId = re.ToString() + R.Next(1, 100).ToString(); universityEmployee.EmpUId = userName; emp.Email = userName; emp.Name = universityEmployee.Name; emp.Surname = universityEmployee.Surname; emp.Gender = universityEmployee.Gender; emp.EmpTYpe = "University Employee"; db.employees.Add(emp); Bs.AddUniversityEmployee(universityEmployee); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UnivbersityId = new SelectList(db.Universities, "UnivbersityId", "UniversityName", universityEmployee.UnivbersityId); return(View(universityEmployee)); }
public ActionResult DeleteConfirmed(string id) { UniversityEmployee universityEmployee = db.UniversityEmployees.Find(id); db.UniversityEmployees.Remove(universityEmployee); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "EmpUId,UnivbersityId,Name,Surname,Email,Gender,EmpTYpe")] UniversityEmployee universityEmployee) { if (ModelState.IsValid) { db.Entry(universityEmployee).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UnivbersityId = new SelectList(db.Universities, "UnivbersityId", "UniversityName", universityEmployee.UnivbersityId); return(View(universityEmployee)); }
public bool RemoveUniversityEmployee(UniversityEmployee universityEmployee) { try { db.UniversityEmployees.Remove(universityEmployee); db.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }
public bool UpdateUniversityEmployee(UniversityEmployee universityEmployee) { try { db.Entry(universityEmployee).State = EntityState.Modified; db.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }
// GET: UniversityEmployees/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UniversityEmployee universityEmployee = db.UniversityEmployees.Find(id); if (universityEmployee == null) { return(HttpNotFound()); } return(View(universityEmployee)); }
// GET: UniversityEmployees/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UniversityEmployee universityEmployee = db.UniversityEmployees.Find(id); if (universityEmployee == null) { return(HttpNotFound()); } ViewBag.UnivbersityId = new SelectList(db.Universities, "UnivbersityId", "UniversityName", universityEmployee.UnivbersityId); return(View(universityEmployee)); }