public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Employee employee = _repository.GetById(id); if (employee == null) { return(HttpNotFound()); } EmployeeEditModel eem = _mapper.Map <EmployeeEditModel>(employee); IRepository <Account> _repoAccount; _repoAccount = kernel.Get <IRepository <Account> >(); eem.Accounts = _repoAccount.GetAll().ToList(); IRepository <Branch> _repoBranch; _repoBranch = kernel.Get <IRepository <Branch> >(); eem.Branches = _repoBranch.GetAll().ToList(); return(View(eem)); }
public IActionResult Edit(EmployeeEditModel employee) { EmployeeBusiness employeeBusiness = new EmployeeBusiness(); var result = employeeBusiness.Edit(employee); return(Ok(result)); }
public virtual async Task <ActionResult> SendMessage(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EmployeeEditModel employee = await GetEmployeeEditModelById(id); if (employee == null) { return(HttpNotFound()); } MessageViewModel msg = new MessageViewModel() { RecipientId = id, }; if (employee.MessageType == MessageTypeEnum.Email) { msg.Length = 500; msg.Type = employee.MessageType; } else { msg.Length = 120; msg.Type = employee.MessageType; } return(View(msg)); }
public async Task <IActionResult> Edit(EmployeeEditModel model) { EmployeeForEditModel employeeEditModel; if (!ModelState.IsValid) { employeeEditModel = await employeeService.PrepeareEmployeeForEditAsync(model.Id); ViewBag.Projects = employeeEditModel.Projects.Select(x => new SelectListItem(x.Value, x.Key.ToString(), employeeEditModel.CurrentProjects.Contains(x.Key))); return(View(model)); } var result = await employeeService.Edit(model); if (result.Succeeded) { return(RedirectToAction(nameof(Index))); } employeeEditModel = await employeeService.PrepeareEmployeeForEditAsync(model.Id); ViewBag.Projects = employeeEditModel.Projects.Select(x => new SelectListItem(x.Value, x.Key.ToString(), employeeEditModel.CurrentProjects.Contains(x.Key))); ModelState.AddModelError(string.Empty, result.Message); return(View(model)); }
public ActionResult Edit(EmployeeEditModel employeeEditModel) { employeeEditModel.EmployeeModel.PasswordHash = "temp"; if (ModelState.IsValid) { if (employeeEditModel.EditPassword != null) { db.Entry(employeeEditModel.EmployeeModel).State = EntityState.Modified; employeeEditModel.EmployeeModel.PasswordSalt = HashHelper.CreateSalt(); employeeEditModel.EmployeeModel.PasswordHash = HashHelper.Hash(employeeEditModel.EditPassword.ToCharArray(), employeeEditModel.EmployeeModel.PasswordSalt); db.SaveChanges(); return(RedirectToAction("Index")); } else { var currentEmployee = db.Employee.FirstOrDefault(e => e.EmployeeID == employeeEditModel.EmployeeModel.EmployeeID); currentEmployee.Email = employeeEditModel.EmployeeModel.Email; currentEmployee.Firstname = employeeEditModel.EmployeeModel.Firstname; currentEmployee.Lastname = employeeEditModel.EmployeeModel.Lastname; currentEmployee.RoleID = employeeEditModel.EmployeeModel.RoleID; db.SaveChanges(); return(RedirectToAction("Index")); } } ViewBag.RoleID = new SelectList(db.Role, "RoleID", "Role1", employeeEditModel.EmployeeModel.RoleID); return(View(employeeEditModel)); }
public PartialViewResult Categories_edit(string cat_id, string arr) { //deserialize myArray JavaScriptSerializer js = new JavaScriptSerializer(); var myojb = (List <TopicCheck>)js.Deserialize(arr, typeof(List <TopicCheck>)); var topicchecks = (List <TopicCheck>)Session["TopicChecked"]; foreach (var item in myojb) { if (topicchecks.Any(tc => item.topic_seq == tc.topic_seq)) { var remove = topicchecks.Where(x => x.topic_seq == item.topic_seq).Single(); topicchecks.Remove(remove); var topic = new TopicCheck(); topic.topic_seq = item.topic_seq; topic.category_id = db.Topic_Category.Where(x => x.Topic_Seq == item.topic_seq).Select(x => x.Category_ID).FirstOrDefault().ToString(); topic.topic_name = db.Topics.Find(item.topic_seq).Topic_Name; topic.topic_ind = item.topic_ind; topicchecks.Add(topic); } } var viewModel = new EmployeeEditModel(); viewModel.topicchecks = topicchecks; if (cat_id != null) { var id = (string)js.Deserialize(cat_id, typeof(string)); viewModel.topicchecks = (from tc in viewModel.topicchecks where tc.category_id == id select tc).ToList(); } return(PartialView("Categories_edit", viewModel)); }
public ReturnResult <Employee> Edit(EmployeeEditModel employee) { DbProvider dbProvider = new DbProvider(); string outCode = String.Empty; string outMessage = String.Empty; StoredProcedureConfigs <Employee> storedProcedureConfigs = new StoredProcedureConfigs <Employee>(); dbProvider.SetQuery(storedProcedureConfigs._UPDATE_SINGLE_STORED_PROCEDURE, CommandType.StoredProcedure) .SetParameter("Id", SqlDbType.Int, employee.Pk_id, ParameterDirection.Input) .SetParameter("Name", SqlDbType.NVarChar, employee.Name, ParameterDirection.Input) .SetParameter("Dob", SqlDbType.DateTime, employee.Dob, ParameterDirection.Input) .SetParameter("Gender", SqlDbType.Int, employee.Gender, ParameterDirection.Input) .SetParameter("PhoneNumber", SqlDbType.Int, employee.PhoneNumber, ParameterDirection.Input) .SetParameter("FK_ComputerRoomId", SqlDbType.Int, employee.FK_ComputerRoomId, ParameterDirection.Input) .SetParameter("FK_ProvinceId", SqlDbType.Int, employee.FK_ProvinceId, ParameterDirection.Input) .SetParameter("Status", SqlDbType.Int, employee.Status, ParameterDirection.Input) .SetParameter("EditBy", SqlDbType.NVarChar, employee.EditBy, ParameterDirection.Input) .SetParameter("ERROR_CODE", SqlDbType.NVarChar, DBNull.Value, 100, ParameterDirection.Output) .SetParameter("ERROR_MESSAGE", SqlDbType.NVarChar, DBNull.Value, 400, ParameterDirection.Output) .ExcuteNonQuery() .Complete(); dbProvider.GetOutValue("ERROR_CODE", out outCode) .GetOutValue("ERROR_MESSAGE", out outMessage); return(new ReturnResult <Employee>() { ErrorCode = outCode, ErrorMessage = outMessage, }); }
public async Task <ActionResult> Edit(EmployeeEditModel Employee) { Employee.EditBy = _userSessionHelper.GetUserSession().UserName; string apiUrl = _appUrlHelper.GetApiUrl(ApiUrlPath.EMPLOYEE_EDIT); var result = await HttpUtilities.PostAsyncApi <ReturnResult <EmployeeEditModel> >(apiUrl, JsonConvert.SerializeObject(Employee)); return(Json(result)); }
public async Task UpdateAsync(EmployeeEditModel model) { var employee = await employeeRepository.FindByKeyAsync(model.ID); Mapper.Map(model, employee); employeeRepository.Update(employee); await DbContext.SaveChangesAsync(); }
public async Task <IActionResult> Edit(int id, [Bind("Id,First_name,Last_name,Street,City,State,Zip_code,Email,Fax,Sex,Work_phone,Status,Ssn,Salary,Date_hired,Termination_date,Birth_date,Bene_health_ins,Bene_life_ins,Bene_day_care,Position_en,Extension,Acces_level,Manager,DepartmentNumber,Job")] EmployeeEditModel employeeEdit) { var employee = new Employee { Id = id, First_name = employeeEdit.First_name, Last_name = employeeEdit.Last_name, Street = employeeEdit.Street, City = employeeEdit.City, State = employeeEdit.State, Zip_code = employeeEdit.Zip_code, Email = employeeEdit.Email, Fax = employeeEdit.Fax, Sex = employeeEdit.Sex, Work_phone = employeeEdit.Work_phone, Status = employeeEdit.Status, Ssn = employeeEdit.Ssn, Salary = employeeEdit.Salary, Date_hired = employeeEdit.Date_hired == null ? DateTime.Now : DateTime.Parse(employeeEdit.Date_hired), Termination_date = employeeEdit.Termination_date == null ? DateTime.Now : DateTime.Parse(employeeEdit.Termination_date), Birth_date = employeeEdit.Birth_date == null ? DateTime.Now : DateTime.Parse(employeeEdit.Birth_date), Bene_life_ins = employeeEdit.Bene_health_ins, Bene_health_ins = employeeEdit.Bene_health_ins, Bene_day_care = employeeEdit.Bene_day_care, Position_en = employeeEdit.Position_en, Extension = employeeEdit.Extension, Acces_level = employeeEdit.Acces_level, Manager = employeeEdit.Manager, Job = employeeEdit.Job, Department = employeeEdit.DepartmentNumber }; if (id != employee.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(employee); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(employee.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(employee)); }
public ActionResult Edit(string id, EmployeeEditModel viewModel) { var topicchecks = (List <TopicCheck>)Session["TopicChecked"]; //TODO: validate to make sure at least one role is selected if (ModelState.IsValid) { Registered_Person rp = db.Registered_Person.Find(id); rp.Person_ID = id; rp.Person_Name = viewModel.person_name; rp.Person_Surname = viewModel.person_surname; rp.Person_Email = viewModel.person_email; rp.Person_Type = "Employee"; db.Entry(rp).State = EntityState.Modified; var roleRemove = db.Person_Role.Where(x => x.Person_ID == id); foreach (var item in roleRemove) { db.Person_Role.Remove(item); } foreach (var item in viewModel.emprolecheckeditlist) { if (item.role_ind == true) { var pRole = new Person_Role(); pRole.Person_ID = id; pRole.Role_ID = item.role_id; db.Person_Role.Add(pRole); } } var trainerRemove = db.Trainer_Topic.Where(x => x.Person_ID == id); foreach (var item in trainerRemove) { db.Trainer_Topic.Remove(item); } if (viewModel.emprolecheckeditlist.Where(x => x.role_id == 7).Where(y => y.role_ind == true).Any()) { foreach (var item in topicchecks) { if (item.topic_ind == true) { var tTopic = new Trainer_Topic(); tTopic.Person_ID = id; tTopic.Topic_Seq = item.topic_seq; db.Trainer_Topic.Add(tTopic); } } } db.SaveChanges(); } TempData["Check2"] = false; ViewBag.Person_Type = new SelectList(db.Person_Type, "Person_Type1", "Person_Type1", 2); return(RedirectToAction("Index")); }
public ActionResult Edit(EmployeeEditModel eem) { if (ModelState.IsValid) { Employee employee = _mapper.Map <Employee>(eem); _repository.Edit(employee); return(RedirectToAction("Index")); } return(View()); }
public async Task <IActionResult> Edit( EmployeeEditModel model) { var employee = await _db.Employees .FindAsync(model.Id); _mapper.Map(model, employee); return(RedirectToAction(nameof(Index))); }
public IActionResult Edit(EmployeeEditModel model) { var employee = _dbContext.tblEmployees.Find(model.EmployeeID); employee.EmployeeID = model.EmployeeID; employee.EmployeeName = model.EmployeeName; employee.SkillID = model.SkillID; employee.YearsExperience = model.YearsExperience; _dbContext.SaveChanges(); return(RedirectToAction("Index")); }
public virtual async Task <ActionResult> Edit(EmployeeEditModel employee) { if (ModelState.IsValid) { var model = _mapper.Map <EmployeeEditModel, Employee>(employee); await _empService.UpdateAsync(model); return(RedirectToAction(MVC.Employee.Actions.Index())); } return(View(employee)); }
public IActionResult Edit(EmployeeEditModel model) { var employee = _dbContext.Employees.Find(model.EmployeeId); employee.Name = model.Name; employee.Address = model.Address; employee.CompanyName = model.CompanyName; employee.Designation = model.Designation; employee.Salary = model.Salary; _dbContext.SaveChanges(); return(RedirectToAction("Index")); }
public List <string> SaveEmployee(EmployeeEditModel employeeEditModel) { List <string> errors = new List <string>(); if (string.IsNullOrWhiteSpace(employeeEditModel.Name)) { errors.Add("Campul Numele nu poate fi gol"); } if (string.IsNullOrWhiteSpace(employeeEditModel.Surname)) { errors.Add("CampulPrenumele nu poate fi gol"); } if (string.IsNullOrWhiteSpace(employeeEditModel.PIN)) { errors.Add("Campul CNP nu poate fi gol"); } if (string.IsNullOrWhiteSpace(employeeEditModel.StreetName)) { errors.Add("Campul Strada nu poate fi gol"); } if (string.IsNullOrWhiteSpace(employeeEditModel.StreetNo)) { errors.Add("Campul Nr Strada nu poate fi gol"); } if (employeeEditModel.StateId == 0) { errors.Add("Campul Stare nu poate fi gol"); } if (employeeEditModel.DepartmentId == 0) { errors.Add("Campul Stare nu poate fi gol"); } if (employeeEditModel.PositionId == 0) { errors.Add("Campul Stare nu poate fi gol"); } if (employeeEditModel.PositionId != (int)SysPositionEnum.CEO) { if (employeeEditModel.ManagerId == 0) { errors.Add("Campul Manager nu poate fi gol"); } } if (!errors.Any()) { errors.AddRange(_employeeService.SaveEmployee(employeeEditModel)); } return(errors); }
public async Task <IActionResult> Create(EmployeeEditModel editModel) { var employeeToAdd = new Employee { Name = editModel.Name, Surname = editModel.Surname }; _context.Add(employeeToAdd); // EntityState.Added await _context.SaveChangesAsync(); return(RedirectToAction("Index")); }
public IActionResult Edit(int id) { var _employees = _dbContext.tblEmployees.Where(e => e.EmployeeID == id).FirstOrDefault(); var employeeEdit = new EmployeeEditModel() { EmployeeID = _employees.EmployeeID, EmployeeName = _employees.EmployeeName, PhoneNumber = _employees.PhoneNumber, SkillID = _employees.SkillID, YearsExperience = _employees.YearsExperience }; ViewBag.Skills = GetSkills(); return(View(employeeEdit)); }
public IActionResult Edit(int id) { var _employees = _dbContext.Employees.Where(e => e.EmployeeId == id).FirstOrDefault(); var employeeEdit = new EmployeeEditModel() { EmployeeId = _employees.EmployeeId, Name = _employees.Name, Address = _employees.Address, CompanyName = _employees.CompanyName, Designation = _employees.Designation, Salary = _employees.Salary }; return(View(employeeEdit)); }
public virtual async Task <ActionResult> Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EmployeeEditModel employee = await GetEmployeeEditModelById(id); if (employee == null) { return(HttpNotFound()); } return(View(employee)); }
public async Task <IActionResult> Edit(EmployeeEditModel inputModel) { if (!ModelState.IsValid) { return(this.View(inputModel)); } var result = await this.employeeService.EditEmployee(inputModel); if (!result.Success) { return(this.View(inputModel)); } return(this.RedirectToAction(nameof(Details), new { id = result.Data.Id })); }
public async Task <bool> Delete(EmployeeEditModel entity) { var p = new DynamicParameters(); p.Add("id", entity.Id); p.Add("DeletedBy", entity.DeletedBy); p.Add("updatedby", entity.UpdatedBy); p.Add("Xoa", entity.Xoa); using (var con = GetConnection()) { await con.ExecuteAsync("sp_Employee_Delete_v2", p, commandType : CommandType.StoredProcedure); return(true); } }
public ActionResult Edit(string id) { var employee = db.Employees.Find(id); var user = UserManager.FindById(id); var isLockedOut = UserManager.IsLockedOut(id); var model = new EmployeeEditModel { Firstname = employee.Firstname, Lastname = employee.Lastname, Middlename = employee.Middlename, // Ticket 103 District = employee.District }; return(View(model)); }
public async Task <IHttpActionResult> Create(EmployeeEditModel newEmployee) { if (!ModelState.IsValid) { return(BadRequest()); } var errors = _employeeValidator.GetErrors(newEmployee); if (errors.Any()) { return(BadRequest(string.Join(" ", errors))); } var newEmployeeId = await _employeeCrud.Create(newEmployee); return(Ok(newEmployeeId)); }
public ActionResult Edit(EmployeeEditModel model) { if (ModelState.IsValid) { var employee = db.Employees.Find(model.ID); employee.Firstname = model.Firstname; employee.Lastname = model.Lastname; employee.Middlename = model.Middlename; // Ticket 103 employee.District = model.District; db.Entry(employee).State = EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("Index")); }
public async Task <JsonResult> Update([FromBody] EmployeeEditModel model) { var isAdmin = GlobalData.User.UserType == (int)UserTypeEnum.Admin ? true : false; if (!isAdmin) { return(ToJsonResponse(false, "Dữ liệu không hợp lệ")); } if (model == null || model.Id <= 0) { return(ToJsonResponse(false, "Dữ liệu không hợp lệ")); } model.UpdatedBy = GlobalData.User.IDUser; var result = await _rpEmployee.Update(model); return(ToJsonResponse(result)); }
// GET: Employees/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var employeeEditModel = new EmployeeEditModel { EmployeeModel = db.Employee.Find(id) }; if (employeeEditModel == null) { return(HttpNotFound()); } ViewBag.RoleID = new SelectList(db.Role, "RoleID", "Role1", employeeEditModel.EmployeeModel.RoleID); return(View(employeeEditModel)); }
public async Task <bool> Update(EmployeeEditModel entity) { var p = new DynamicParameters(); p.Add("id", entity.Id); p.Add("fullName", entity.FullName); p.Add("phone", entity.Phone); p.Add("roleId", entity.RoleId); p.Add("email", entity.Email); p.Add("UpdatedBy", entity.UpdatedBy); using (var con = GetConnection()) { await con.ExecuteAsync("sp_Employee_UpdateUser_v2", p, commandType : CommandType.StoredProcedure); return(true); } }
public async Task <ResultData <EmployeeEditModel> > CreateEmployeeEditModel(int id) { Employee employee = await this.employeeRepository.GetEmployeeById(id); if (employee == null) { return(new ResultData <EmployeeEditModel>(EmployeeNotFoundMessage, false, null)); } EmployeeEditModel model = new EmployeeEditModel { Id = employee.Id, FirstName = employee.FirstName, LastName = employee.LastName, ExperienceLevel = employee.ExperienceLevel, Salary = employee.Salary }; return(new ResultData <EmployeeEditModel>(EmployeeEditModelCreatedMessage, true, model)); }