//Takım-Get public ActionResult Team() { if (online() == false) { return(RedirectToAction("Login", "Security")); } string ro = Session["Role"].ToString(); if (ro != "Patron") { return(RedirectToAction("blog", "Admin", new { id = 1 })); } empview e = new empview(); e.epm = db.employes.ToList(); e.usr = db.user.ToList(); return(View(e)); }
//Takım ekleme-Post public ActionResult Teamadd(HttpPostedFileBase foto, empview e) {//0-çalışan//1-stajyerlise//2-stajyerüni if (online() == false) { return(RedirectToAction("Login", "Security")); } try { string ro = Session["Role"].ToString(); string s = ""; if (ro == "Patron") { if (foto != null) { user usr = new user(); usr.userEmail = e.userEmail; usr.userName = e.userName; usr.userPhone = e.userPhone; int i = Convert.ToInt32(e.userRole); if (i == 0) { usr.userRole = "Çalışan"; s = "Çalışan Eklendi"; } else if (i == 1) { usr.userRole = "Stajyer-Lise"; s = "Stajyer-Lise Eklendi"; } else { usr.userRole = "Stajyer-Üniversite"; s = "Stajyer-Üniversite Eklendi"; } usr.userSurname = e.userSurname; db.user.Add(usr); db.SaveChanges(); var u = db.user.Where(x => x.userPhone == usr.userPhone && x.userEmail == usr.userEmail).FirstOrDefault(); process(u.userId, "user", s); var newuser = db.user.Where(x => x.userEmail == e.userEmail && x.userPhone == e.userPhone).FirstOrDefault(); employe emp = new employe(); WebImage img = new WebImage(foto.InputStream); FileInfo fotoinfo = new FileInfo(foto.FileName); string newfoto = Guid.NewGuid().ToString() + fotoinfo.Extension; img.Resize(600, 400); img.Save("~/Image/employeImage/" + newfoto); emp.employeImage = "~/Image/employeImage/" + newfoto; emp.employePassword = e.employePassword; emp.userId = newuser.userId; db.employes.Add(emp); db.SaveChanges(); } return(RedirectToAction("Team", "Admin")); } else { return(RedirectToAction("blog", "Admin", new { id = 1 })); } } catch (Exception ex) { return(RedirectToAction("Error", "Home", new { ex = ex })); } }