public ActionResult Edit(int id) { var service = CreateEmployeeService(); var detail = service.GetEmployeeById(id); List <Department> Departments = CreateDepartmentService().GetDepartmentsData().ToList(); ViewBag.DeptId = Departments.Select(o => new SelectListItem() { Value = o.DeptId.ToString(), Text = o.DeptName, Selected = o.DeptId == detail.DeptId }); var model = new EmployeeEdit { EmpId = detail.EmpId, FullName = detail.FullName, Phone = detail.Phone, Email = detail.Email, Gender = detail.Gender, TypeOfPosition = detail.TypeOfPosition, DeptId = detail.DeptId }; return(View(model)); }
private void BtnAdd_Click(object sender, EventArgs e) { var userForms = new EmployeeEdit(); userForms.Closed += propFormClosed; userForms.Show(); }
public ActionResult EditPost() { var employee = _employeeService.Employees.Where(x => x.User_Id == GetUserId() && x.IsActive).First(); var viewModel = new EmployeeEdit(employee) { Positions = _postionService.Positions.Select(x => new SelectListItem() { Value = x.Id.ToString(), Text = x.Name }), IsAdmin = User.IsInRole(Data.Enums.Role.Admin.ToString()) }; if (!TryUpdateModel(viewModel) || !ModelState.IsValid) { return(View(viewModel)); } try { var toModel = viewModel.ToEmployee(); _employeeService.Update(toModel); } catch (Exception ex) { return(View(viewModel)); throw ex; } return(RedirectToAction("Index", "Home")); }
public ActionResult View(int id, string returnUrl) { var employee = _employeeService.Employees.FirstOrDefault(x => x.Id == id && x.IsActive); if (employee == null) { return(RedirectToAction("Index", "Home")); } var viewModel = new EmployeeEdit(employee) { Positions = _postionService.Positions.Select(x => new SelectListItem() { Value = x.Id.ToString(), Text = x.Name }), IsAdmin = User.IsInRole(Data.Enums.Role.Admin.ToString()), OrderList = employee.Order.OrderByDescending(x => x.ModifyDate).Take(5).Select(n => new OrderList { Id = n.Id, Customer = string.Format("{0} {1}", n.Customer.Name, n.Customer.Surname), Status = n.OrderStatus.Name }) }; return(View(viewModel)); }
public ActionResult Edit(int id) { ViewData["Managers"] = _db.Managers.Select(e => new SelectListItem { Text = e.ManagerFirstName + " " + e.ManagerLastName, Value = e.ManagerId.ToString() }); var service = CreateEmployeeService(); var detail = service.GetEmployeeById(id); var model = new EmployeeEdit { EmployeeId = detail.EmployeeId, EmployeeFirstName = detail.EmployeeFirstName, EmployeeLastName = detail.EmployeeLastName, ManagerId = detail.ManagerId, ManagerFullName = detail.ManagerFullName, HiredDate = detail.HiredDate, Dept = detail.Dept, }; return(View(model)); }
public IActionResult Edit(EmployeeEdit model) { if (ModelState.IsValid) { Employee employee = _employeeRespository.GetEmployee(model.Id); employee.Name = model.Name; employee.Id = model.Id; employee.Email = model.Email; employee.Capcity = model.Capacity; employee.Location = model.Location; employee.Price = model.Price; Employee newEmployee = new Employee { Name = employee.Name, Email = employee.Email, Id = employee.Id, Photos = employee.Photos, Capcity = employee.Capcity, Location = employee.Location, Price = employee.Price }; _employeeRespository.Update(employee); return(RedirectToAction("Property")); } return(View()); }
public bool UpdateEmployee(EmployeeEdit model) { using (_context) { var entity = _context .Employees .Single(e => e.PersonID == model.PersonID && e.UserID == _userID); entity.PersonID = model.PersonID; entity.EmployeeID = model.EmployeeID; entity.HireDate = model.HireDate; entity.FirstName = model.FirstName; entity.LastName = model.LastName; entity.JobTitle = model.JobTitle; entity.StreetAddress = model.StreetAddress; entity.City = model.City; entity.State = model.State; entity.ZipCode = model.ZipCode; entity.PhoneNumber = model.PhoneNumber; entity.Email = model.Email; entity.TerminationDate = entity.TerminationDate; return(_context.SaveChanges() == 1); } }
private bool checkFIDCard(EmployeeEdit input, out Employee employee) { employee = _ERepository.GetAll().SingleOrDefault(p => p.FIDCard == input.FIDCard && p.Id != input.Id); if (employee != null) { return(false); } return(true); }
// GET: Employees/Edit/5 public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } // Creates a new instance of the EmployeeEdit view model EmployeeEdit viewModel = new EmployeeEdit(); // Grabs the Current Employee and Attatches Computer and TrainingProgram Tables viewModel.Employee = await _context.Employee .Include(e => e.Department) .Include("EmployeeComputers.Computer") .Include("EmployeeTrainingPrograms.TrainingProgram") .SingleOrDefaultAsync(m => m.EmployeeID == id); // Makes Sure the Employee is Actually There if (viewModel.Employee == null) { return(NotFound()); } // Calls the PopulateTrainingProgramList Method, The current Employee is passed in as an argument PopulateTrainingProgramList(viewModel.Employee); // Creates a new Select List that will Allow you to Select a different department in the view ViewData["DepartmentID"] = new SelectList(_context.Set <Department>(), "DepartmentID", "Name", viewModel.Employee.DepartmentID); // Grabs all Computers and attatches EmployeeComputers Join Table var allComputers = await _context.Computer.Include("EmployeeComputers").ToListAsync(); // Creates a new instance of a list of computers var availableComputers = new List <Computer>(); // Loops Over all Computers and only adds the available computers that are unassagined foreach (var computer in allComputers) { if (!(computer.EmployeeComputers.Any(ec => ec.DateUnassigned == null))) { availableComputers.Add(computer); } } // Grabs the current Employees Computer var CurrentCompAssignment = viewModel.Employee.EmployeeComputers.SingleOrDefault(m => m.DateUnassigned == null); // If The current Employee has a computer, it is added to the available computer list and the computer ID is attached to the view model if (CurrentCompAssignment != null) { availableComputers.Add(CurrentCompAssignment.Computer); viewModel.SelectedComputerID = CurrentCompAssignment.ComputerID; } // Creates a new select list with the available computers ViewData["Computers"] = new SelectList(availableComputers, "ComputerID", "Make", viewModel.SelectedComputerID); return(View(viewModel)); }
public bool UpdateEmployee(EmployeeEdit model) { using (ApplicationDbContext ctx = new ApplicationDbContext()) { Employee entity = ctx.Employees.SingleOrDefault(e => e.EmployeeId == model.EmployeeId && e.EmployeeGuid == _userId); entity.FirstName = model.FirstName; entity.LastName = model.LastName; entity.HiringDate = model.HiringDate; //entity.Shifts = model.Shifts; return(ctx.SaveChanges() == 1); } }
public IHttpActionResult Put(EmployeeEdit model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateEmployeeService(); if (!service.UpdateEmployee(model)) { return(InternalServerError()); } return(Ok()); }
public ActionResult Edit(string id) { var service = CreateEmployeeService(); var detail = service.GetEmployeeById(id); var model = new EmployeeEdit { FullName = detail.FullName, Title = detail.Title, PayRate = detail.PayRate }; return(View(model)); }
//PUT public bool UpdateEmployee(EmployeeEdit model) { using (var db = new ApplicationDbContext()) { var employee = db.Employees.Single(e => e.Id == model.Id); employee.Id = model.Id; employee.FirstName = model.FirstName; employee.LastName = model.LastName; employee.MuseumId = model.MuseumId; employee.Position = model.Position; return(db.SaveChanges() == 1); } }
//GET: Employee/Edit{id} public ActionResult Update(int id) { EmployeeService service = CreateEmployeeService(); EmployeeDetail detail = service.GetEmployeeById(id); EmployeeEdit model = new EmployeeEdit { EmployeeId = detail.EmployeeId, FirstName = detail.FirstName, LastName = detail.LastName, HiringDate = detail.HiringDate, //Shifts = detail.Shifts }; return(View(model)); }
public ViewResult Edit(int id) { Employee employee = _employeeRespository.GetEmployee(id); EmployeeEdit employeeEdit = new EmployeeEdit { Id = employee.Id, Email = employee.Email, Name = employee.Name, Capacity = employee.Capcity, Location = employee.Location, Price = employee.Price }; return(View(employeeEdit)); }
private void BtnEdit_Click(object sender, EventArgs e) { if (GVEmployee.SelectedRows.Count != 1) { MessageBox.Show(this, TMConstants.Dialog.MANY_SELECTION, TMConstants.Dialog.Captions.WARNING, MessageBoxButtons.OK); } else { EmployeeId = GVEmployee.SelectedRows[0].Cells[0].Value.ToString(); var empForm = new EmployeeEdit(); empForm.Closed += propFormClosed; empForm.Show(); } }
public ActionResult Edit(string id) { EmployeeEdit employeeEdit = new EmployeeEdit(); var intId = 0; int.TryParse(id, out intId); try { Employee employee = employeeRepository.GetEmployeeById(intId); if (employee == null) { return(RedirectToAction("Error404", "Error")); } else { var path = ""; var fileName = employee.Id + ".jpg"; var savePath = Server.MapPath("~/Uploads/employee/") + employee.Id; // Check for Directory, If not exist, then create it if (Directory.Exists(savePath)) { path = "/Uploads/employee/" + employee.Id + "/" + fileName; employee.Image = path; } else { savePath = Server.MapPath("~/Uploads/"); fileName = "default.jpg"; } employeeEdit.ImageStream = ImageHelper.BaseDateImage(savePath + "/" + fileName); employee.Image = Common.ConcatHost(path); } var objPosition = employeeRepository.GetPosition(); employeeModel = new EmployeeModels { employee = employee, positions = objPosition, employeeEdit = employeeEdit, checkPost = false }; } catch (Exception ex) { log.Error(ex); ModelState.AddModelError("error", Translator.UnexpectedError); } return(View(employeeModel)); }
// GET: Employee/Edit/5 public ActionResult Edit(int id) { var service = CreateEmployeeService(); var detail = service.GetEmployeeById(id); var model = new EmployeeEdit { EmployeeId = detail.EmployeeId, AvailableHours = detail.AvailableHours, Rating = detail.Rating, Name = detail.Name, WageAmount = detail.WageAmount }; return(View(model)); }
public bool UpdateEmployee(EmployeeEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Employees .Single(e => e.Employee_Id == model.Employee_Id); entity.Title = model.Title; entity.FullName = model.FullName; entity.PayRate = (decimal)model.PayRate; return(ctx.SaveChanges() == 1); }; }
public ActionResult Edit(int id) { var service = CreateEmployeeService(); var detail = service.GetEmployeeById(id); var model = new EmployeeEdit { EmployeeId = detail.EmployeeId, FirstName = detail.FirstName, LastName = detail.LastName, JobTitle = detail.JobTitle, LevelOfEducation = detail.LevelOfEducation }; return(View(model)); }
public ActionResult Edit() { var employee = _employeeService.Employees.Where(x => x.User_Id == GetUserId() && x.IsActive).First(); var viewModel = new EmployeeEdit(employee) { Positions = _postionService.Positions.Select(x => new SelectListItem() { Value = x.Id.ToString(), Text = x.Name }), IsAdmin = User.IsInRole(Data.Enums.Role.Admin.ToString()) }; return(View(viewModel)); }
public bool UpdateEmployee(EmployeeEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Employees .Single(e => e.EmployeeId == model.EmployeeId && e.OwnerId == _userId); entity.EmployeeId = model.EmployeeId; entity.FirstName = model.FirstName; entity.LastName = model.LastName; entity.JobTitle = model.JobTitle; entity.LevelOfEducation = model.LevelOfEducation; entity.ModifiedUtc = DateTimeOffset.UtcNow; return(ctx.SaveChanges() == 1); } }
public bool UpdateEmployee(EmployeeEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Employees .Single(e => e.EmpId == model.EmpId); //.Single(e => e.EmpId == model.EmpId && e.IndividualId == _userId); entity.EmpId = model.EmpId; entity.FullName = model.FullName; entity.Phone = model.Phone; entity.Email = model.Email; entity.Gender = model.Gender; entity.TypeOfPosition = model.TypeOfPosition; entity.DeptId = model.DeptId; return(ctx.SaveChanges() == 1); } }
public bool UpdateEmployee(EmployeeEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Employees .Single(e => e.EmployeeId == model.EmployeeId && e.ManagerId == _userId); entity.EmployeeId = model.EmployeeId; entity.Name = model.Name; entity.WageAmount = model.WageAmount; entity.CanClose = model.CanClose; entity.CanOpen = model.CanOpen; entity.AvailableHours = model.AvailableHours; entity.Rating = model.Rating; return(ctx.SaveChanges() == 1); } }
public async Task <Employee> Update(EmployeeEdit input) { if (!string.IsNullOrEmpty(input.FIDCard)) { Employee emp; if (!checkFIDCard(input, out emp)) { throw new UserFriendlyException($"【{input.FIDCard}】此ID卡已绑定到员工【{emp.FName}】,不能重复绑定,请换卡!"); } } var entity = input.MapTo <Employee>(); long userid; //修改员工对应用户信息 CreateOrUpdateUser(input, out userid); if (input.FDepartment > 0) //部门ID { var treelist = _Repository.GetAll().Where(p => p.IsDeleted == false).ToList(); //查找部门的那条数据 var eneiety = _Repository.GetAll().Include(p => p.Parent) .SingleOrDefault(p => p.Id == input.FDepartment && p.IsDeleted == false); if (eneiety != null) { var resultjt = GetCompany(eneiety, treelist); entity.FOrganizationUnitId = resultjt.Id; } } entity.FTenantId = this.AbpSession.TenantId.HasValue ? this.AbpSession.TenantId.Value : 0; entity.FERPUser = input.FERPUser; entity.FERPOfficeClerk = input.FERPOfficeClerk; entity.FUserId = (userid != 0 && input.FUserId == 0)?userid:input.FUserId; entity.IsDeleted = false; entity.FHiredate = (entity.FHiredate == null || entity.FHiredate == DateTime.MinValue)? DateTime.Now:entity.FHiredate; var count = await _ERepository.UpdateAsync(entity); return(count); }
public bool UpdateEmployee(EmployeeEdit model) { using (var ctx = new ApplicationDbContext()) { var employeeName = ctx.Employees.Find(model.EmployeeId); var managerName = ctx.Managers.Find(model.ManagerId); var entity = ctx .Employees .Single(e => e.EmployeeId == model.EmployeeId && e.EmployeeOwnerId == _userId); entity.EmployeeFirstName = model.EmployeeFirstName; entity.EmployeeLastName = model.EmployeeLastName; entity.HiredDate = model.HiredDate; entity.ManagerId = model.ManagerId; entity.Dept = model.Dept; return(ctx.SaveChanges() == 1); } }
public void E2E2_EditEmployee() { Index indexPage = new Index(_driver, BASE_URL, _wait); indexPage.Open(); indexPage.GoToEmployees(); EmployeesList listPage = new EmployeesList(_driver, BASE_URL, _wait); EmployeeDataRow employee = listPage.GetLast(); listPage.Loading(); string employeeId = employee.EmployeeID.Text; Assert.False(string.IsNullOrEmpty(employeeId)); Assert.AreEqual("Test Employee", employee.Name.Text); Assert.AreEqual("Test Address", employee.Address.Text); Assert.AreEqual("test@email", employee.Email.Text); Assert.AreEqual("123-456-789", employee.PhoneNumber.Text); listPage.EditEmployee(employee); EmployeeEdit editPage = new EmployeeEdit(_driver, BASE_URL, employeeId, _wait); editPage.Email.Clear(); editPage.Email.SendKeys("newtest@email"); editPage.PhoneNumber.Clear(); editPage.PhoneNumber.SendKeys("123-456-789new"); editPage.SaveEmployee(); listPage = new EmployeesList(_driver, BASE_URL, _wait); employee = listPage.GetLast(); listPage.Loading(); Assert.AreEqual("newtest@email", employee.Email.Text); Assert.AreEqual("123-456-789new", employee.PhoneNumber.Text); }
public ActionResult Edit(String id, EmployeeEdit Model) { if (!ModelState.IsValid) { return(View(Model)); } if (Model.Employee_Id != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(Model)); } var service = CreateEmployeeService(); if (service.UpdateEmployee(Model)) { TempData["Save Result"] = "Your change was updated"; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your change could not be updated"); return(View()); }
public ActionResult Edit(EmployeeEdit model) { //if (!ModelState.IsValid) return View(model); //if(model.EmployeeId != id) //{ // ModelState.AddModelError("", "Incorrect Id"); // return View(model); //} var service = CreateEmployeeService(); if (service.UpdateEmployee(model)) { TempData["SaveResult"] = "The Employee was updated successfully!"; return(RedirectToAction("Index")); } //ModelState.AddModelError("", "The Employee was not updated!"); return(View(model)); }
public ActionResult Edit(int id, EmployeeEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.EmpId != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } var service = CreateEmployeeService(); if (service.UpdateEmployee(model)) { TempData["SaveResult"] = "The employee was updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "The employee could not be updated."); return(View(model)); }