public object Update(String account, EmployeeReq req) { try { var result = context.Employee.FirstOrDefault(value => value.Account == account); if (result != null) { result.Account = req.Account; result.Pass = req.Pass; result.LastName = req.LastName; result.FirstName = req.FirstName; result.DateOfBirth = req.DateOfBirth; result.Gender = req.Gender; result.CitizenIdentification = req.CitizenIdentification; result.Address = req.Address; result.PhoneNumberOfEmployee = req.PhoneNumberOfEmployee; result.Email = req.Email; result.CreatedDate = req.CreatedDate; result.AccountStatus = req.AccountStatus; result.Note = req.Note; context.Employee.Update(result); context.SaveChanges(); return(result); } else { return("Unable to update: not found ID."); } } catch (Exception ex) { return(ex.StackTrace); } }
public SingleResponse UpdateEmployee(EmployeeReq req) { //Khởi tạo var result = new SingleResponse(); Employees emp = new Employees(); //Gán emp.PhoneNumber = req.PhoneNumber; emp.LastName = req.LastName; emp.FirstName = req.FirstName; emp.EmpBirthDay = req.EmpBirthDay; emp.EmpEmail = req.EmpEmail; emp.EmpGender = req.EmpGender; emp.Street = req.Street; emp.Ward = req.Ward; emp.District = req.District; emp.Province = req.Province; emp.Country = req.Country; emp.EmpIdentityCard = req.EmpIdentityCard; emp.Position = req.Position; emp.Seniority = req.Seniority; emp.CoefficientsSalary = req.CoefficientsSalary; emp.EmpNote = req.EmpNote; //Sửa result = base.Update(emp); result.Data = emp; return(result); }
protected void btnsubmit_Click(object sender, EventArgs e) { string msg = ""; try { EmployeeReq objEmployeeReq = new EmployeeReq(); objEmployeeReq.FullName = txtFirstName.Text + " " + txtLastName.Text; objEmployeeReq.EmployeeCode = txtEmployeecode.Text; objEmployeeReq.Desgination = txtDesgination.Text; objEmployeeReq.JoningDate = txtDOJ.Text; objEmployeeReq.Experince = txtExperience.Text; objEmployeeReq.Skills = txtSkills.Text; objEmployeeReq.Salary = txtSallery.Text; objEmployeeReq.Email = txtMailId.Text; if (ddlType.SelectedIndex == 2) { objEmployeeReq.Role = "admintesting"; } else { objEmployeeReq.Role = ddlType.SelectedItem.Text; } objEmployeeReq.UserType = ddlUserType.SelectedItem.Text; objEmployeeReq.Password = "******"; if (txtDepartment.Text != "") { objEmployeeReq.DepartmetnID = txtDepartment.Text; } else { objEmployeeReq.DepartmetnID = ddlDepartment.SelectedItem.Value; } WebClient client = new WebClient(); client.Headers[HttpRequestHeader.ContentType] = "text/json"; string data = JsonConvert.SerializeObject(objEmployeeReq); string result = client.UploadString(URL + "/addEmployee", "POST", data); Response response = JsonConvert.DeserializeObject <Response>(result); if (response.isValid) { clearAll(); string add = "User Add Successfully !"; Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "Success('" + add + "');", true); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "OnError('" + response.Error + "');", true); } } catch (Exception ex) { } }
public static EmployeeReq editUser(string id) { EmployeeReq listEmployee = new EmployeeReq(); try { WebClient webClient = new WebClient(); webClient.Headers[HttpRequestHeader.ContentType] = "application/json"; var data = JsonConvert.SerializeObject(id); var res = webClient.UploadString(URL + "/getUser", "POST", data); MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(res)); DataContractJsonSerializer recv = new DataContractJsonSerializer(typeof(Response)); Response httpResponse = (Response)recv.ReadObject(ms); if (httpResponse.isValid) { var dt = httpResponse.DS.Tables[0]; if (dt.Rows.Count > 0) { listEmployee.FullName = dt.Rows[0][1].ToString(); listEmployee.EmployeeCode = dt.Rows[0][4].ToString(); listEmployee.Email = dt.Rows[0][2].ToString(); listEmployee.Desgination = dt.Rows[0][5].ToString(); listEmployee.Experince = dt.Rows[0][7].ToString(); listEmployee.Skills = dt.Rows[0][8].ToString(); listEmployee.Salary = dt.Rows[0][9].ToString(); listEmployee.JoningDate = dt.Rows[0][6].ToString(); listEmployee.Role = dt.Rows[0][10].ToString(); } } } catch (Exception ex) { throw; } return(listEmployee); }
public object CreateEmployee(EmployeeReq req) { Employee employee = new Employee(); employee.Account = req.Account; employee.Pass = req.Pass; employee.LastName = req.LastName; employee.FirstName = req.FirstName; employee.DateOfBirth = req.DateOfBirth; employee.Gender = req.Gender; employee.CitizenIdentification = req.CitizenIdentification; employee.Address = req.Address; employee.PhoneNumberOfEmployee = req.PhoneNumberOfEmployee; employee.Email = req.Email; employee.CreatedDate = req.CreatedDate; employee.AccountStatus = req.AccountStatus; employee.Note = req.Note; return(employeeRep.Create(employee)); }
public IActionResult UpdateEmployee(String account, EmployeeReq req) { var result = employeeSvc.UpdateEmployee(account, req); return(Ok(result)); }
public IActionResult CreateEmployee(EmployeeReq req) { var result = employeeSvc.CreateEmployee(req); return(Ok(result)); }
public object UpdateEmployee(String account, EmployeeReq req) { return(employeeRep.Update(account, req)); }
public IActionResult UpdateCustomer([FromBody] EmployeeReq req) { var result = _svc.UpdateEmployee(req); return(Ok(result)); }