protected void btnSave_Click(object sender, EventArgs e) { var obj = new EMPLOYEE(); obj.DEPARTMENT_ID = Convert.ToInt32(ddlDepartment.SelectedValue); obj.EMPLOYEE_CODE = popTxtEmployeeCode.Text; obj.EMPLOYEE_NAME = txtName.Text; obj.EMPLOYEE_SURNAME = txtLastName.Text; var cmd = new EmployeeService(obj); if (flag.Text.Equals("Add")) { obj.Action = ActionEnum.Create; obj.CREATE_DATE = DateTime.Now; obj.CREATE_EMPLOYEE_ID = 0; obj.UPDATE_DATE = DateTime.Now; obj.UPDATE_EMPLOYEE_ID = 0; obj.SYE_DEL = true; cmd.Add(); } else { obj.Action = ActionEnum.Update; obj.EMPLOYEE_ID = Convert.ToInt32(ViewState["empId"].ToString()); obj.UPDATE_DATE = DateTime.Now; obj.UPDATE_EMPLOYEE_ID = 0; obj.SYE_DEL = true; cmd.Edit(); } ViewState["empId"] = null; Response.Redirect("SearchEmployee.aspx"); }
public ResultViewModel <EmployeeEditViewModel> Post(EmployeeEditViewModel model) { ResultViewModel <EmployeeEditViewModel> result = new ResultViewModel <EmployeeEditViewModel>(); try { if (!ModelState.IsValid) { result.Message = "In Valid Model State"; } else { EmployeeEditViewModel selectedUser = EmployeeService.Add(model); result.Successed = true; result.Data = selectedUser; } } catch (Exception ex) { result.Successed = false; result.Message = "حدث خطأ ما"; } return(result); }
private void button1_Click(object sender, EventArgs e) { EmployeeService employeeService = new EmployeeService(); int count = Convert.ToInt32(employeeService.RowCount()); count += 1001; Employee employee = new Employee(); employee.Id = count; employee.Name = nameBox.Text; employee.Password = passwordBox.Text; employee.Designation = (string)designationBox.SelectedItem; employee.Address = addressBox.Text; employee.Phone = phoneBox.Text; employee.Email = emailBox.Text; employee.Gender = (string)genderBox.SelectedItem; if (employeeService.Add(employee) > 0 && phoneBox.Text.Length == 11) { MessageBox.Show("Record Added Succesfully"); } else { MessageBox.Show("Error Please provide a valid phone number"); } }
public override void Apply() { if (IsPasswordChanging && HasRights) { if (AdditionalPassword == Password) { this.Entity = EmployeeService.SetPassword(Entity, Password); } else { _shell.MessageQueue.Enqueue("Пароли не совпадают"); return; } } try { if (IsNew) { _employees.Add(this.Entity); } else { _employees.Update(this.Entity); } } catch (Exception) { _shell.OpenDialogByUri(CompanyUris.ConnectionLost, false, null); return; } _shell.NavigateByUri(CompanyUris.Hub); }
public void Add() { if (IsEdit == true) { ToEdit.FirstName = FirstName; ToEdit.LastName = LastName; ToEdit.EmploymentDate = EmploymentDate; ToEdit.Email = Email; ToEdit.PhoneNumber = PhoneNumber; ToEdit.Workplace = Workplace; EmployeeService.Edit(ToEdit); } else { var newEmployee = new EmployeeDTO(); newEmployee.FirstName = FirstName; newEmployee.LastName = LastName; newEmployee.EmploymentDate = EmploymentDate; newEmployee.Email = Email; newEmployee.PhoneNumber = PhoneNumber; newEmployee.Workplace = Workplace; EmployeeService.Add(newEmployee); } Close(); }
public void Add() { if (!IsEdit) { string x = EmployeeService.Add(NationalId, FirstName, LastName, Salary, SelectedSpecialization?.Id, DateOfEmployment, SelectedRank?.Id); if (x == null) { TryClose(); } else { Error = x; } } else { toEdit.NationalId = NationalId; toEdit.FirstName = FirstName; toEdit.LastName = LastName; toEdit.Salary = Salary; toEdit.DateOfEmployment = DateOfEmployment; toEdit.SpecializationId = SelectedSpecialization.Id; toEdit.RankId = SelectedRank.Id; string x = EmployeeService.Edit(toEdit); if (x == null) { TryClose(); } else { Error = x; } } }
public void ADD_ShouldReturnEmployeeAdded() { //Arrange int x = 6; var employee = new Employee() { EmployeeId = x, FirstName = "Miguel", LastName = "Cruz", Age = 26 }; var options = new DbContextOptionsBuilder <CinemaDbContext>() .UseInMemoryDatabase(databaseName: "ADD_ShouldReturnEmployeeAdded") .UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking) .Options; var context = new CinemaDbContext(options); SeedEmployees(context); var service = new EmployeeService(context); //Act var result = service.Add(employee); //Assert Assert.True(result); }
public void ExecuteAdd() { Employee e = new Employee(MyEmployee.Id, MyEmployee.Name, MyEmployee.Age); _employeeService.Add(e); LoadData(); }
private void btnOK_Click(object sender, EventArgs e) { if (InvalidFields() == true) { MessageBox.Show("Looks like you did not enter all the fields correctly"); return; } if (_validator.ValidateBirthdateAndAge(dtDateOfBirth.Value, (int)nudAge.Value) == false) { MessageBox.Show("The entered birthdate and age does not match!"); return; } var employee = CreateEmployee(); if (_employeeService.GetEmployeeByEmpNo(employee.EmpNo) != null) { MessageBox.Show("EmpNo has to be unique!"); return; } txtDetails.Text = employee.ToString(); _employeeService.Add(employee); }
public void Add_Employee_Test(string error, string expected) { //Arrange var fakeEmployee = new EmployeeModel() { Id = 1, Name = "Utfake", Surname = "Fake1", PasswordClear = "fTest", Type = EmployeeType.Ordinal, Email = "*****@*****.**", StartDate = new DateTime(2014, 02, 25), EndDate = new DateTime(2016, 02, 25), }; Mock <IEmployeeRepository> repository = new Mock <IEmployeeRepository>(); repository.Setup(c => c.Add(It.IsAny <EmployeeModel>())).Returns(error); var employeeService = new EmployeeService(repository.Object); //Act var result = employeeService.Add(fakeEmployee); //Assert Assert.AreEqual(result, expected); }
public void CreateAndDelete() { // Идеально Имеет место создавать тестовую бд перед выполнением, а // мы сдеаем два теста в одном, но так делать нельзя с идеологической точки зрения, да и не только!!! // они НЕ ДОЛЖНЫ зависить друг от друга и проверять каждый должен конкретный свой аспект EmployeeDTO newEmployee = new EmployeeDTO { FName = "asd", IName = "sd", OName = "asd", Probation = false, QualificationId = 1, DepartmentId = 1 }; Task <IBaseDTO> t = _service.Add(newEmployee); t.Wait(); var newDto = t.Result as EmployeeDTO; Assert.IsNotNull(newDto, "Создание"); Task <bool> t2 = _service.Delete(newDto.Id); t.Wait(); bool result = t2.Result; Assert.IsTrue(result, "Удаление"); }
public void AddEmployee() { var employee = new Employee(); _service.Add(employee); _repository.Received().Add(employee); }
public ActionResult Create(EmployeeViewModel modl) { if (ModelState.IsValid) { _EmployeeService.Add(modl.objemplyee); return(RedirectToAction("Index")); } return(View("Create", modl)); }
/// <summary> /// Thêm /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtEmployeeID.Text)) { XtraMessageBox.Show("Mã Nhân Viên không được bỏ trống!", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtEmployeeID.Focus(); } else if (string.IsNullOrEmpty(txtEmployeeCode.Text)) { XtraMessageBox.Show("Mã Code của Nhân viên không được bỏ trống!", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtEmployeeCode.Focus(); } else if (string.IsNullOrEmpty(txtEmployeeName.Text)) { XtraMessageBox.Show("Tên Nhân Viên không được bỏ trống!", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtEmployeeName.Focus(); } else if (string.IsNullOrEmpty(gridLookUpEdit1.Text)) { XtraMessageBox.Show("Bạn phải chọn một Bộ Phận cho Nhân viên này!", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Warning); gridLookUpEdit1.Focus(); } else { var employee = new Employee() { EmployeeID = txtEmployeeID.Text, EmployeeCode = txtEmployeeCode.Text, DepartmentID = gridLookUpEdit1.EditValue.ToString(), EmployeeName = txtEmployeeName.Text, HomeTell = txtPhone.Text, Mobile = txtMoblie.Text, Address = txtAddress.Text, Email = txtEmail.Text, IsActive = checkActive.Checked, IsManagerStock = true, }; try { _employeeService.Add(employee); InsertSysLog(txtEmployeeName.Text); if (XtraMessageBox.Show("Thêm thành công.\n Bạn có muốn thêm mới Nhân Viên nữa không?", "HỎI", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { ResetControls(); } else { DialogResult = DialogResult.No; } } catch (Exception ex) { XtraMessageBox.Show(string.Format("Lỗi {0}", ex.Message), "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public string Execute(params string[] arguments) { string firstName = arguments[0]; string lastName = arguments[1]; decimal salary = decimal.Parse(arguments[2]); employeeService.Add(firstName, lastName, salary); return($"{firstName} {lastName} added successfuly"); }
public void CreateFakeEmployee() { var svc = new EmployeeService(GetOauthConnection()); var newEmployee = svc.Add(GetFakeEmployee()); var employees = svc.List().ToList(); Assert.NotEmpty(employees); Assert.True(employees.Any(e => e.Id.Equals(newEmployee.Id))); }
public RedirectResult Add(Employee data) { if (empService.Any(x => x.UserName == data.UserName)) { return(Redirect("/CRMarea/Employee/List")); } //PassCrypto.base64Encode(data.Password); empService.Add(data); return(Redirect("/CRMarea/Employee/List")); }
public void Add_ThrowCustomException_EmployeeIsNull() { var mockUOW = new Mock <IUnitOfWork>(); EmployeeDTO employee = null; mockUOW.Setup(x => x.EmployeeRepository.Add(It.IsAny <Employee>())); var service = new EmployeeService(mockUOW.Object, Helper.GetMapper()); Assert.ThrowsAsync <CustomException>(() => service.Add(employee)); }
public ActionResult Create([Bind(Include = "FirstName,LastName,MiddleName,Email")] EmployeeVM model) { if (ModelState.IsValid) { EmployeeDTO employeeDTO = Mapper.Map <EmployeeDTO>(model); EmployeeService.Add(employeeDTO); return(RedirectToAction("Index")); } return(View(model)); }
public ActionResult Create(Employee model) { model.ActionOperationType = EActionOperationType.Create; if (ModelState.IsValid) { EmployeeService service = new EmployeeService(); service.Add(model); return RedirectToAction("Index"); } this.LoadEditViewBag(model); return View("Create",model); }
public void EmployeeService_Should_Add_Employee() { var repository = new Mock <IEmployeeRepository>(); var employeeService = new EmployeeService(repository.Object); //Act repository.Setup(x => x.Add(It.IsAny <EmployeeAddRequest>())).Returns(true); var result = employeeService.Add(new EmployeeAddRequest()); //Assert Assert.IsTrue(result); }
public ActionResult Add(AddViewModel avm) { if (avm.Id == null) { return(View(avm)); } else { Employee emp = new Employee(avm.Id, avm.Name, avm.Salary, avm.DeptNo); empService.Add(emp); return(View()); } }
public void Add_Employee_ArgumentNullException_Test(Type expectedException, string expectedVar) { //Arrange Mock <IEmployeeRepository> repository = new Mock <IEmployeeRepository>(); var employeeService = new EmployeeService(repository.Object); //Assert var ex = Assert.Throws(expectedException, () => employeeService.Add(null)); Assert.That(ex.Message.Contains(expectedVar)); }
public ActionResult AddOrUpdateEmployee([FromBody] EmployeeViewModel employee) { var mappedResult = Mapper.Map <EmployeeViewModel, Employee> (employee); if (employee.Id == 0) { var result = EmployeeService.Add(mappedResult); return(Ok(result)); } EmployeeService.Update(mappedResult); return(Ok()); }
public ActionResult Add(AddViewModel vm) { if (vm.Employee.Id == 0 || vm.Employee.Name == null || vm.Employee.DeptNo == 0) { return(View(vm)); } else { EmployeeService svc = new EmployeeService(); svc.Add(vm.Employee); return(RedirectToAction("Index")); } }
public void Add() { var newEmployee = new EmployeeDTO(); newEmployee.FirstName = FirstName; newEmployee.LastName = LastName; newEmployee.EmploymentDate = EmploymentDate; newEmployee.Email = Email; newEmployee.PhoneNumber = PhoneNumber; newEmployee.Workplace = Workplace; EmployeeService.Add(newEmployee); TryClose(); }
public void AddEmployee() { // Arrange int elementsCountBeforeAct = mockEmployeeRepository.Employees.Count(); EmployeeDTO employeeDTO = new EmployeeDTO(); // Act EmployeeService.Add(employeeDTO); // Assert Assert.AreNotEqual(elementsCountBeforeAct, mockEmployeeRepository.Employees.Count()); Assert.IsTrue(mockEmployeeRepository.Employees.Count() > elementsCountBeforeAct); }
public IActionResult Create(EmployeeEditViewModel model) { if (ModelState.IsValid) { var emp = new Employee(); emp.Code = model.Code; emp.Name = model.Name; emp.Remark = model.Remark; var empService = new EmployeeService(_context); empService.Add(emp); return(RedirectToAction("Detail", new { id = emp.Id })); } return(View()); }
private async Task Save() { EmployeeModel.ManagerId = Managers?.SingleOrDefault(employee => employee.Id.Equals(EmployeeId))?.Id; EmployeeModel.DepartmentId = Departments?.SingleOrDefault(department => department.Id.Equals(DepartmentId))?.Id; if (Id != 0) { await EmployeeService.Update(EmployeeModel); } else { await EmployeeService.Add(EmployeeModel); } NavigationService.Previous(); }
public async Task Add_Employee_Collection_Should_Call_Repository() { var employees = new EmployeeDTO[2]; var employeesMapped = new Employee[1]; mapperMock.Setup(m => m.Map <IEnumerable <Employee> >(employees)).Returns(employeesMapped); await employeeService.Add(employees); employeeRepositoryMock.Verify(e => e.Add(employeesMapped), Times.Once); employeeRepositoryMock.VerifyNoOtherCalls(); mapperMock.Verify(m => m.Map <IEnumerable <Employee> >(employees), Times.Once); mapperMock.VerifyNoOtherCalls(); }
public void Add_ThrowCustomException_EmployeeNameLengthZero() { var mockUOW = new Mock <IUnitOfWork>(); EmployeeDTO employee = new EmployeeDTO() { Id = 1, Name = "", Surname = "surname" }; mockUOW.Setup(x => x.EmployeeRepository.Add(It.IsAny <Employee>())); var service = new EmployeeService(mockUOW.Object, Helper.GetMapper()); Assert.ThrowsAsync <CustomException>(() => service.Add(employee)); }
public ActionResult Create(Employee employee) { try { if (ModelState.IsValid) { employeeService.Add(employee); return(RedirectToAction("Index")); } } catch (DataException) { ModelState.AddModelError("", "Không thể tạo nhân viên!"); } return(View(employee)); }
public ActionResult Create(EmployeeViewModel viewModel) { if (!ModelState.IsValid) { return View(viewModel); } using (ModelRepository db = new ModelRepository(this._factory.GetDatabaseObject())) { EmployeeService service = new EmployeeService(db); service.Add(this._toBusinessModel(viewModel)); db.SaveChanges(); } return RedirectToAction("Index"); }