public ActionResult EditEmp(int id) { if (Session["EmpName"] != null) { using (EmpDbContext empDb = new EmpDbContext()) { //SqlParameter param1 = new SqlParameter("@EmployeeId", id); //var employee = empDb.Employees.SqlQuery(@"Exec GetEmpById @EmployeeId", param1).Single(); var result = (from s in empDb.Employees where s.EmployeeId == id select s).FirstOrDefault(); if (result != null) { ViewBag.CountryList = new SelectList(GetCountryList(), "CountryId", "CountryName"); if (result.CountryId != null) { var coID = (int)result.CountryId; ViewBag.StatesList = new SelectList(GetStatesList(coID), "StateId", "StateName"); } return(View(result)); } else { return(View()); } } } else { return(RedirectToAction("Index")); } }
public ActionResult EmpDetails(int id) { //if (Session["EmpName"] != null) //{ using (EmpDbContext empDb = new EmpDbContext()) { var result = (from s in empDb.Employees where s.EmployeeId == id select s).FirstOrDefault(); if (result != null) { return(View(result)); } else { return(View()); } } //} //else //{ // return RedirectToAction("Index"); //} }
public List <Country> GetCountryList() { using (EmpDbContext db = new EmpDbContext()) { List <Country> countries = db.Countries.ToList(); return(countries); } }
public List <States> GetStatesList(int couID) { using (EmpDbContext db = new EmpDbContext()) { List <States> states = db.States.Where(x => x.CountryId == couID).ToList(); return(states); } }
public ActionResult GetStateList(int CountryId) { using (EmpDbContext db = new EmpDbContext()) { List <States> stateList = db.States.Where(x => x.CountryId == CountryId).ToList(); ViewBag.StateOptions = new SelectList(stateList, "StateId", "StateName"); return(PartialView("_StateOptionPartial")); } }
public ActionResult ImageRetrieve(int imgID) { using (EmpDbContext db = new EmpDbContext()) { var img = db.FileUploads.SingleOrDefault(x => x.ImageId == imgID); return(File(img.Imagelength, "image/jpg")); } }
public ActionResult Index(string UserName, string Password) { if (ModelState.IsValid) { try { using (EmpDbContext db = new EmpDbContext()) { // var result = db.Users.FirstOrDefault(u => u.UserName == UserName && u.Password == Password); var result = (from s in db.Users where s.UserName == UserName || s.Email == UserName select s).FirstOrDefault(); if (result != null) { var hashCode = result.Vcode; //Password Hasing Process Call Helper Class Method var encodingPasswordString = Helper.EncodePassword(Password, hashCode); //Check Login Detail User Name Or Password var query = (from s in db.Users where (s.UserName == UserName || s.Email == UserName) && s.Password.Equals(encodingPasswordString) select s).FirstOrDefault(); var empdb = new EmpDbContext(); if (query != null) { var getrole = (from s in empdb.Roles where (s.Roleid == query.Roleid) select s).FirstOrDefault(); Session["EmpName"] = Convert.ToString(result.UserName); Session["EmpID"] = Convert.ToInt32(result.Empid); Session["RoleID"] = Convert.ToInt32(result.Roleid); Session["Role"] = Convert.ToString(getrole.RoleName); Session["SessionExpire"] = false; return(RedirectToAction("About")); } else { ViewBag.Message = "Invalid Password"; return(View()); } } else { ViewBag.Message = "Invalid UserName and Password"; return(View()); } } } catch (Exception e) { logger.ErrorException("Error occured in Home controller Index Action", e); ViewBag.Message = "Error Login"; return(View()); } } else { return(View()); } }
public ActionResult Register() { var p = new User(); using (EmpDbContext db = new EmpDbContext()) { p.RoleList = db.Roles.ToList(); } return(View(p)); //return View(); }
public ActionResult DeleteSiteSettings(int SiteID) { // SiteSettings model = new SiteSettings(); using (EmpDbContext db = new EmpDbContext()) { SiteSettings sitelist = db.siteSettings.SingleOrDefault(x => x.SettingsID == SiteID); sitelist.Checkstatus = "N"; db.SaveChanges(); } return(RedirectToAction("SiteSetting", "Utility")); }
public ActionResult Index() { //Session.Abandon(); using (EmpDbContext dba = new EmpDbContext()) { var ado = dba.Employees.ToList(); return(View()); } //return View(); }
public ActionResult DeleteRole(int RoleID) { Role model = new Role(); using (EmpDbContext db = new EmpDbContext()) { Role rolelist = db.Roles.SingleOrDefault(x => x.Roleid == RoleID); rolelist.Checkstatus = "N"; db.SaveChanges(); } return(RedirectToAction("Roles", "Utility")); }
public ActionResult DeleteTech(int TechId) { Technologies model = new Technologies(); using (EmpDbContext Techdb = new EmpDbContext()) { Technologies techlist = Techdb.Technologies.SingleOrDefault(x => x.TechId == TechId); techlist.Checkstatus = "N"; Techdb.SaveChanges(); } return(RedirectToAction("Index", "Technology")); }
public ActionResult PrintDetails(int id) { using (EmpDbContext empDb = new EmpDbContext()) { //var result = (from s in empDb.Employees where s.EmployeeId == id select s).FirstOrDefault(); var result = empDb.Employees.Where(x => x.EmployeeId == id).ToList(); if (result != null) { return(PartialView("_Printpdf", result)); } return(null); } }
public ActionResult Contact() { if (Session["EmpName"] != null) { ViewBag.Message = "Your contact page."; var employees = new EmpDbContext(); return(View(employees.Employees.ToList())); } else { return(RedirectToAction("Index")); } }
public ActionResult Roles() { if (Session["EmpName"] != null) { var db = new EmpDbContext(); ViewBag.Roles = db.Roles.Where(x => x.Checkstatus == "Y").ToList(); return(View()); } else { return(RedirectToAction("Index", "Home")); } }
// GET: Technology public ActionResult Index() { if (Session["EmpName"] != null) { var tech = new EmpDbContext(); ViewBag.listcount = Convert.ToInt32(tech.Technologies.Where(x => x.Checkstatus == "Y").ToList().Count()); ViewBag.tech = tech.Technologies.Where(x => x.Checkstatus == "Y").ToList(); return(View()); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult Register(User user) { if (ModelState.IsValid) { try { using (EmpDbContext db = new EmpDbContext()) { var chkUser = (from s in db.Users where s.UserName == user.UserName || s.Email == user.Email select s).FirstOrDefault(); if (chkUser == null) { var keyNew = Helper.GeneratePassword(10); var password = Helper.EncodePassword(user.Password, keyNew); user.Password = password; //user.Checkstatus = "Y"; user.Vcode = keyNew; db.Users.Add(user); db.SaveChanges(); ModelState.Clear(); ViewBag.Message = "Registration Successful"; //var emailpassword = "******"; //var sub = "Sample application Registration"; //var body = "You have been succesfully registered in Sample application"; //RegEmail(user.Email, sub, body, emailpassword); return(RedirectToAction("Index", "Home")); } var p = new User(); p.RoleList = db.Roles.ToList(); ViewBag.Message = "User Already Exists!"; return(View(p)); } } catch (Exception e) { logger.ErrorException("Error occured in registration", e); ViewBag.Message = "Some exception occured" + e; return(RedirectToAction("Register")); } } else { ViewBag.Message = "Registration Failed"; return(RedirectToAction("Register")); } }
public void ActivateSiteSetting(int SiteID) { using (EmpDbContext db = new EmpDbContext()) { SiteSettings Inactivate = db.siteSettings.Where(x => x.IsActive == true).FirstOrDefault(); if (Inactivate != null) { Inactivate.IsActive = false; } SiteSettings sitelist = db.siteSettings.SingleOrDefault(x => x.SettingsID == SiteID); sitelist.IsActive = true; db.SaveChanges(); } }
public ActionResult Create(int id) { if (Session["EmpName"] != null) { using (EmpDbContext db = new EmpDbContext()) { var x = db.FileUploads.Where(a => a.Checkstatus == "Y"); return(View()); } } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult AddEditRole(int RoleID) { Role model = new Role(); using (EmpDbContext db = new EmpDbContext()) { if (RoleID > 0) { var rolelist = db.Roles.SingleOrDefault(x => x.Roleid == RoleID); model.Roleid = rolelist.Roleid; model.RoleName = rolelist.RoleName; } } return(PartialView("_AddEditRole", model)); }
public ActionResult AddEditTechnology(Technologies technologies) { if (Session["EmpName"] != null) { if (ModelState.IsValid) { try { using (EmpDbContext Techdb = new EmpDbContext()) { if (technologies.TechId > 0) { //update Technologies techlist = Techdb.Technologies.SingleOrDefault(x => x.TechId == technologies.TechId); techlist.Technology = technologies.Technology; techlist.Description = technologies.Description; Techdb.SaveChanges(); } else { //Insert //Technologies techins = new Technologies(); //techins.Technology = technologies.Technology; //techins.Description = technologies.Description; technologies.Checkstatus = "Y"; Techdb.Technologies.Add(technologies); Techdb.SaveChanges(); } } ModelState.Clear(); return(RedirectToAction("Index", technologies)); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Technology", "Index"))); } } return(RedirectToAction("AddEditTechnology", technologies.TechId)); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult Index() { if (Session["EmpName"] != null) { using (EmpDbContext db = new EmpDbContext()) { ViewBag.tech = db.FileUploads.Where(x => x.Checkstatus == "Y").ToList(); //var x = db.FileUploads.ToList(); return(View()); } } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult AddEditTechnology(int TechID) { Technologies model = new Technologies(); using (EmpDbContext Techdb = new EmpDbContext()) { if (TechID > 0) { Technologies techlist = Techdb.Technologies.SingleOrDefault(x => x.TechId == TechID); model.TechId = techlist.TechId; model.Technology = techlist.Technology; model.Description = techlist.Description; } } return(PartialView("_Create", model)); }
public ActionResult EmpDelete(int id) { if (Session["EmpName"] != null) { using (EmpDbContext empDb = new EmpDbContext()) { var result = (from s in empDb.Employees where s.EmployeeId == id select s).FirstOrDefault(); empDb.Employees.Remove(result); empDb.SaveChanges(); } return(RedirectToAction("Contact")); } else { return(RedirectToAction("Index")); } }
public ActionResult SiteSetting() { if (Session["EmpName"] != null) { using (EmpDbContext db = new EmpDbContext()) { ViewBag.SettingsList = db.siteSettings.Where(x => x.Checkstatus == "Y").ToList(); ViewBag.ListCount = (from row in db.siteSettings where row.Checkstatus == "Y" select row).Count(); return(View()); } } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult AddEditRole(Role role) { if (Session["EmpName"] != null) { if (ModelState.IsValid) { try { using (EmpDbContext db = new EmpDbContext()) { if (role.Roleid > 0) { //update Role rolelist = db.Roles.SingleOrDefault(x => x.Roleid == role.Roleid); rolelist.RoleName = role.RoleName; db.SaveChanges(); } else { //Insert role.Checkstatus = "Y"; db.Roles.Add(role); db.SaveChanges(); } } ModelState.Clear(); return(RedirectToAction("Roles", "Utility")); } catch (Exception ex) { //return View("Error", new HandleErrorInfo(ex, "Utility", "Roles")); } } return(RedirectToAction("AddEditRole", role.Roleid)); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult AddEmp(Employee employee) { if (Session["EmpName"] != null) { try { if (ModelState.IsValid) { using (EmpDbContext empDb = new EmpDbContext()) { using (DbContextTransaction transaction = empDb.Database.BeginTransaction()) { try { empDb.Employees.Add(employee); empDb.SaveChanges(); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); Console.WriteLine("Error occurred."); } } } ModelState.Clear(); return(RedirectToAction("Contact")); } return(View()); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "EmployeeInfo", "Create"))); } } else { return(RedirectToAction("Index")); } }
public ActionResult EditEmp(Employee employee) { if (Session["EmpName"] != null) { try { using (EmpDbContext empDb = new EmpDbContext()) { var data = (from a in empDb.Employees where a.EmployeeId == employee.EmployeeId select a).FirstOrDefault(); data.Company = employee.Company; data.CountryId = employee.CountryId; data.StateId = employee.StateId; data.Description = employee.Description; data.IsEmployeeRetired = employee.IsEmployeeRetired; data.Name = employee.Name; data.EmpDate = employee.EmpDate; data.IsActive = employee.IsActive; empDb.Entry(data).State = EntityState.Modified; empDb.SaveChanges(); } return(RedirectToAction("Contact")); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "EmployeeInfo", "Create"))); } // return RedirectToAction("EditEmp"); } else { return(RedirectToAction("Index")); } }
public ActionResult MenuManagement(FormCollection collection) { if (Session["EmpName"] != null) { using (EmpDbContext db = new EmpDbContext()) { var menulist = db.MenuManagement.Where(x => x.Checkstatus == "Y").Select(p => p.Menu_NAME).ToList(); List <int> applist = new List <int>(); StringBuilder sb = new StringBuilder(); // sb.Append("0"); foreach (var item in menulist) { if (!string.IsNullOrEmpty(collection[item])) { var checkResp = collection[item].Split(',')[0]; if (checkResp != "false") { //sb.Append(", " + int.Parse(checkResp)); sb.Append(int.Parse(checkResp) + " ,"); } } } var rid = int.Parse(collection["hdnroleid"]); var menures = sb.ToString(); var result = (from s in db.Roles where s.Roleid == rid select s).FirstOrDefault(); result.Menu_display = menures.Remove(menures.Length - 1); db.SaveChanges(); } return(RedirectToAction("Roles")); } else { return(RedirectToAction("Index", "Home")); } }
public JsonResult Create(FileUpload img, HttpPostedFileBase ImageFile) { EmpDbContext db = new EmpDbContext(); int imageId = 0; var file = ImageFile; //byte[] imagebyte = null; if (file != null) { string filename = Path.GetFileName(file.FileName); file.SaveAs(Server.MapPath("/Assets/" + filename)); //BinaryReader reader = new BinaryReader(file.InputStream); Stream stream = file.InputStream; BinaryReader binaryReader = new BinaryReader(stream); Byte[] image = binaryReader.ReadBytes((int)stream.Length); //imagebyte = reader.ReadBytes(file.ContentLength); FileUpload fimg = new FileUpload { FileName = filename, Imagelength = image, ImagePath = "/Assets/" + filename, Checkstatus = "Y" }; db.FileUploads.Add(fimg); db.SaveChanges(); imageId = fimg.ImageId; } return(Json(imageId, JsonRequestBehavior.AllowGet)); }