// GET: Employee/DeleteEmp/5 public ActionResult DeleteEmp(int id) { try { EmpRepository EmpRepo = new EmpRepository(); if (EmpRepo.DeleteEmployee(id)) { ViewBag.AlertMsg = "Employee details deleted successfully"; } return(RedirectToAction("GetAllEmpDetails")); } catch { return(View()); } }
public ActionResult AddEmployee(EmployeeModel Emp) { try { if (ModelState.IsValid) { EmpRepository EmpRepo = new EmpRepository(); EmpRepo.AddEmployee(Emp); ViewBag.Message = "Records added successfully."; } return(View()); } catch { return(View()); } }
// GET: Delete Employee details by id public ActionResult DeleteEmp(int id, string filename) { try { DeleteBlob(filename); EmpRepository EmpRepo = new EmpRepository(); if (EmpRepo.DeleteEmployee(id)) { ViewBag.AlertMsg = "Employee details deleted successfully"; } return(RedirectToAction("GetAllEmpDetails")); } catch (Exception ex) { return(RedirectToAction("GetAllEmpDetails")); } }
public ActionResult EditEmpDetails(int id, EmpModel obj) { try { EmpRepository EmpRepo = new EmpRepository(); EmpRepo.UpdateEmployee(obj); return(RedirectToAction("GetAllEmpDetails")); } catch { return(View()); } }
public ActionResult AddEmployee(EmpMod Emp) { try { EmpRepository EmpRepo = new EmpRepository(); if (EmpRepo.AddEmployee(Emp)) { ViewBag.Message = "Employee details added Successfully"; } return(RedirectToAction("GetAllEmpDetails")); } catch { return(View()); } }
public ActionResult DeleteEmp(int id) { try { EmpRepository EmpRepo = new EmpRepository(); if (EmpRepo.DeleteEmployees(id)) { ViewBag.AlertMsg = "Employee Details Deleted Successfully"; ViewBag.message.cssClass = "alert alert-danger"; } return(RedirectToAction("GetAllEmpDetails")); } catch { return(View()); } }
public ActionResult EditEmployeeSalary(string id) { ViewBag.Title = "HRMS - Edit Employee Salary"; EmpRepository empRo = new EmpRepository(); ModelState.Clear(); EmpRepository empRep = new EmpRepository(); EmpSalaryModel empSal = empRo.GetSingleEmployeeSalaryOnId(id); string empid = Convert.ToString(empSal.EmpId); EmployeeModel emp = empRep.GetSingleEmployeeOnId(empid); @ViewBag.EmpName = emp.EmpName + " (#" + emp.EmpId.ToString() + ")"; @ViewBag.EmpId = emp.EmpId.ToString(); @ViewBag.SalMonth = empSal.SalaryMonth; return(View(empRo.GetSingleEmployeeSalaryOnId(id))); }
// GET: Employee/DeleteEmp/5 public ActionResult DeleteEmp(int id) { try { EmpRepository EmpRepo = new EmpRepository(); if (EmpRepo.DeleteEmployee(id)) { ViewBag.AlertMsg =“Empleado eliminado"; } return RedirectToAction("GetAllEmpDetails"); } catch { return View(); } }
public ActionResult AddEmployee(EmployeeDetails Emp) { try { if (ModelState.IsValid) { EmpRepository empRepository = new EmpRepository(); if (empRepository.AddEmployee(Emp)) { ViewBag.Message = "Employee details added successfully"; } } return(View()); } catch { return(View()); } }
public void DeleteBlob(string fileName) { EmpRepository erObj = new EmpRepository(); int count = erObj.GetImageCount(fileName); if (count == 1) { EmployeeModel obj = new EmployeeModel(); string path = obj.Url + fileName; CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString")); CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); CloudBlobContainer container = blobClient.GetContainerReference("sarojcontainer"); CloudBlockBlob blob = container.GetBlockBlobReference(fileName);//Changed path to fileName blob.Delete(); } }
public ActionResult AddEmployee(Employee emp) { try { if (ModelState.IsValid) { EmpRepository repo = new EmpRepository(); if (repo.AddEmployee(emp)) { ViewBag.message = "Almacenado Correctamente"; } } return(RedirectToAction("GetAllEmpDetails")); } catch (Exception) { return(View()); } }
public HttpResponseMessage Get(int?id) { try { var empList = new List <EmpModel>(); if (id == null) { empList = EmpRepository.GetAllEmployees(); } else { empList.Add(EmpRepository.GetEmployee(id)); } return(Request.CreateResponse(System.Net.HttpStatusCode.OK, empList)); } catch (Exception ex) { return(Request.CreateErrorResponse(System.Net.HttpStatusCode.NotFound, "Server - Error Fetching Employee Data")); } }
public ActionResult AddEmployee(EmpModel Emp) { try { if (ModelState.IsValid) { EmpRepository EmpRepo = new EmpRepository(); if (EmpRepo.AddEmployee(Emp)) { ViewBag.Message =“Empleado agregado"; } } return View(); } catch { return View(); } }
public ActionResult AddEmployee(EmpModel Emp) { try { if (ModelState.IsValid) { EmpRepository EmpRepo = new EmpRepository(); if (EmpRepo.AddEmployee(Emp)) { ViewBag.Message = "Employee details added successfully"; } } return(View()); } catch (Exception ex) { return(View()); } }
public ActionResult GetAllEmpDetails() { EmpRepository empRo = new EmpRepository(); ModelState.Clear(); bool SearchCriteria = false; string SearchEmployee = Request.Form["txtEmployee"]; string Status = Request.Form["cmbStatus"]; if (!string.IsNullOrEmpty(SearchEmployee)) { if (SearchEmployee.Trim() != "") { SearchCriteria = true; } } if (!string.IsNullOrEmpty(Status)) { SearchCriteria = true; } else { Status = "0"; SearchCriteria = true; } ViewBag.Title = "HRMS - Employee List"; if (SearchCriteria) { return(View(empRo.GetSearchedEmployees(SearchEmployee, Status))); } else { return(View(empRo.GetAllEmployees())); } }
public ActionResult DeleteEmployeeSalary(string id) { EmpSalaryModel EmpSal = new EmpSalaryModel(); EmpSal.id = Convert.ToInt32(id); EmpSal.EmpId = 0; EmpSal.Salary = 0; EmpSal.SalaryYear = 0; EmpSal.SalaryMonth = 0; try { EmpRepository EmpRepo = new EmpRepository(); EmpSal = EmpRepo.GetSingleEmployeeSalaryOnId(id); if (EmpRepo.EmployeeSalaryAddEdit(EmpSal, "delete")) { return(RedirectToAction("EmployeeSalaryList", new { id = EmpSal.EmpId })); } ViewBag.Message = ""; } catch { return(RedirectToAction("GetAllEmpDetails")); } /*ViewBag.Title = "HRMS - Edit Employee Salary"; * EmpRepository empRep = new EmpRepository(); * EmployeeModel emp = empRep.GetSingleEmployeeOnId(EmpSal.EmpId.ToString()); * * @ViewBag.EmpName = emp.EmpName + " (#" + emp.EmpId.ToString() + ")"; * EmpSal = empRep.GetSingleEmployeeSalaryOnId(Convert.ToString(EmpSal.id)); * @ViewBag.SalMonth = EmpSal.SalaryMonth; * @ViewBag.EmpId = emp.EmpId.ToString(); * return View(EmpSal);*/ return(View()); }
public ActionResult EditEmployee(int id) { EmpRepository repo = new EmpRepository(); return(View(repo.GetEmployees().Find(Emp => Emp.id == id))); }
public ActionResult AddEmployee(EmployeeModel Emp, FormCollection image) { //var clientPath = Path.GetDirectoryName(photo.FileName); //var filename = Path.GetFileName(photo.FileName); //var fileName = Path.GetDirectoryName(photo.FileName); //var fileName2 = Path.GetFullPath(photo.FileName); ////HttpPostedFileBase photo = Request.Files["photo"]; ////string ss = form["photo"].ToString(); ////var file2 = Request.Files[0]; try { if (ModelState.IsValid) { //EmpRepository EmpRepo = new EmpRepository(); //if (photo != null && photo.ContentLength > 0) //{ // var fileName = Path.GetFileName(photo.FileName); // var path = Path.Combine(Server.MapPath("~/TempFile/"), fileName); photo.SaveAs(path); // UploadImage_URL(path, fileName); // var fullPath = Server.MapPath("~/TempFile/" + fileName); // if (System.IO.File.Exists(fullPath)) // { // System.IO.File.Delete(fullPath); // //ViewBag.deleteSuccess = "true"; // } //} HttpPostedFileBase fileNameglobal = null; foreach (string item in Request.Files) { HttpPostedFileBase file = Request.Files[item] as HttpPostedFileBase; fileNameglobal = file; if (file.ContentLength == 0) { continue; } if (file.ContentLength > 0) { CloudBlobContainer blobContainer = _blobServices.GetCloudBlobContainer(); CloudBlockBlob blob = blobContainer.GetBlockBlobReference(file.FileName); blob.UploadFromStream(file.InputStream); } } //var fileName = Path.GetFileName(photo.FileName); var fileName = Path.GetFileName(fileNameglobal.FileName); EmpRepository EmpRepo = new EmpRepository(); Emp.ImagePath = fileName; EmpRepo.AddEmployee(Emp); ViewBag.Message = "Records added successfully."; } //return View(); return(RedirectToAction("GetAllEmpDetails")); } catch (Exception ex) { return(View()); } }
public bool Patch(Employee emp) { EmpRepository er = new EmpRepository(); return(er.Patch(emp)); }
public List <Employee> Get() { EmpRepository er = new EmpRepository(); return(er.GetAll()); }
public HomeController() { repository = new EmpRepository(); }
public Employee Get(int ID) { EmpRepository er = new EmpRepository(); return(er.Get(ID)); }
public bool Post(Employee emp) { EmpRepository er = new EmpRepository(); return(er.Post(emp)); }
public ActionResult EditEmployee1() { EmployeeModel Emp = new EmployeeModel(); Emp.EmpId = Convert.ToInt32(Request.Form["EmpId"]); Emp.EmpName = Request.Form["EmpName"]; Emp.Email = Request.Form["Email"]; Emp.State = Request.Form["State"]; Emp.City = Request.Form["City"]; Emp.ZipCode = Request.Form["ZipCode"]; Emp.Address = Request.Form["Address"]; if (Request.Form["Deactive"].Contains("true")) { Emp.Deactive = true; } else { Emp.Deactive = false; } try { bool DuplicateEmail = false; if (ModelState.IsValid) { EmpRepository EmpRepo = new EmpRepository(); if (EmpRepo.CheckDuplicateEmailId(Emp.EmpId.ToString(), Emp.Email.ToString())) { DuplicateEmail = true; } else { if (EmpRepo.EmployeeAddEdit(Emp, "update")) { return(RedirectToAction("GetAllEmpDetails")); } } Emp = EmpRepo.GetSingleEmployeeOnId(Emp.EmpId.ToString()); } if (DuplicateEmail) { ViewBag.ErrorMessage = "Duplicate email!"; } else { ViewBag.ErrorMessage = "System error. Please try again!"; } ViewBag.Message = ""; StateRepository sr = new StateRepository(); var sel = new SelectList(sr.GetAllStates(), "id", "StateName"); ViewBag.Title = "HRMS"; ViewBag.StateList = sel.ToList(); } catch { ViewBag.ErrorMessage = "System error. Please try again!"; ViewBag.Message = ""; StateRepository sr = new StateRepository(); var sel = new SelectList(sr.GetAllStates(), "id", "StateName"); ViewBag.Title = "HRMS"; ViewBag.StateList = sel.ToList(); } return(View(Emp)); }
public bool Update(Employee emp) { EmpRepository er = new EmpRepository(); return(er.Update(emp)); }
// GET: Employee/GetAllEmpDetails public ActionResult GetAllEmpDetails() { EmpRepository EmpRepo = new EmpRepository(); return(View(EmpRepo.GetAllEmployees())); }
// GET: Employee/GetAllEmpDetails URL public ActionResult GetAllEmpDetails() { EmpRepository EmpRepo = new EmpRepository(); Modetate.Clear(); return View(EmpRepo.GetAllEmployees()); }
public bool Delete(int ID) { EmpRepository er = new EmpRepository(); return(er.Delete(ID)); }
// GET: Bind controls to Update details public ActionResult EditEmpDetails(int id) { EmpRepository EmpRepo = new EmpRepository(); return(View(EmpRepo.GetAllEmployees().Find(Emp => Emp.Empid == id))); }
public EmployeesController() { rep = new EmpRepository(); ada = new EmpAdapter(); }