public void TestMethod5() { EmployeeRepo employeeRepo = new EmployeeRepo(); bool success = employeeRepo.GetEmployeesInRange(DateTime.Parse("1/12/2019"), DateTime.Parse("1/12/2020")); Assert.IsTrue(success); }
public void TestMethodUpdate() { OptionInstance.ConfigAutomapper(); EmployeeRepo repo = new EmployeeRepo(@"Persist Security Info=False;Integrated Security=true;Initial Catalog=RJD.Test;Server=localhost"); // TODO: при указании миллисекунд, тест падает DateTime dateTime = new DateTime(2019, 8, 12, 20, 22, 59); var createDto = new EmployeeDto { Id = Guid.NewGuid(), Name = "Иван", Surname = "Иванов" }; repo.Create(createDto); createDto.BornDate = dateTime; repo.Update(createDto); var readDto = repo.Read(createDto.Id); Assert.AreEqual(readDto, createDto); }
// GET: Employee public ActionResult GetAllEmployeeDetails() { EmployeeRepo empRepo = new EmployeeRepo(); ModelState.Clear(); return(View(empRepo.GetDisplayData())); }
public HttpResponseMessage GetEmployeeByUserId(int user_id) { HttpResponseMessage Response = null; try { if (user_id != 0) { EmployeeModel existingInstance = EmployeeRepo.GetEmployeeDetailsByUserId(user_id); if (existingInstance != null) { Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_001", "Success", existingInstance)); } else { Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_403", "Invalid Employee ID", "Invalid Employee ID")); } } else { Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_102", "Invalid Employee ID", "Please check input Json")); } } catch (Exception exception) { Debug.WriteLine(exception.Message); Debug.WriteLine(exception.GetBaseException()); Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_101", "Application Error", exception.Message)); } return(Response); }
public HttpResponseMessage EmployeeSearch(int employee_id = 0, string employee_name = null) //not used { HttpResponseMessage Response = null; try { if (employee_id != 0 || employee_name != null) { List <EmployeeModel> employee_list = EmployeeRepo.SearchEmployee(employee_id, employee_name); if (employee_list.Count != 0) { Response = Request.CreateResponse(new EMSResponseMessage("EMS_001", "Success", employee_list)); } else { Response = Request.CreateResponse(new EMSResponseMessage("EMS_404", "No Employees Found", "No employee found for given name or ID")); } } else { Response = Request.CreateResponse(new EMSResponseMessage("EMS_102", "No id or name found to search", "No id or name found to search")); } } catch (Exception exception) { Debug.WriteLine(exception.Message); Debug.WriteLine(exception.GetBaseException()); Response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_101", "Application Error", exception.Message)); } return(Response); }
//APPROVE public ActionResult Approve(int id) { ViewBag.Employee = new SelectList(EmployeeRepo.Get(), "Id", "First_Name"); SouvenirRequestViewModel model = SouvenirRequestRepo.GetById(id); return(PartialView("_Approve", model)); }
static void Main(string[] args) { EmployeeRepo repo = new EmployeeRepo(); Console.WriteLine("Enter employee id"); var id = int.Parse(Console.ReadLine()); Console.WriteLine("enter employee name"); var name = Console.ReadLine(); Console.WriteLine("enter empployee age"); var age = int.Parse(Console.ReadLine()); Console.WriteLine("enter employee salary"); var salary = double.Parse(Console.ReadLine()); Employee newEmployee = new Employee() { EmployeeID = id, Name = name, Age = age, Salary = salary }; repo.AddEmployeeToList(newEmployee); var newList = repo.GetList(); foreach (Employee e in newList) { Console.WriteLine(e.EmployeeID + " " + e.Name); } Console.ReadKey(); }
public void GivenEmployeeNames_WhenMax_ThenReturnExpectedMaxSalary() { int expected = 300000; EmployeeRepo emprepo = new EmployeeRepo(); int max = emprepo.getMaxSalary(); Assert.AreEqual(expected, max); }
public void GivenEmployeeNames_WhenCountBySalary_ThenReturnExpectedCountBySalary() { int expected = 3; EmployeeRepo emprepo = new EmployeeRepo(); int count = emprepo.getCountSalary(); Assert.AreEqual(expected, count); }
public ActionResult Accordion() { List <Employee> lstemp = new List <Employee>(); Employee objemp = new Employee(); IEnumerable <Employee> ietemp = EmployeeRepo.GetEmployees(); lstemp = (List <Employee>)ietemp; objemp.employeeId = 0; objemp.employeeName = "Please Select"; lstemp.Insert(0, objemp); ViewData["empList"] = lstemp; HttpCookie _userInfoCookies = Request.Cookies["UserInfo"]; if (_userInfoCookies != null) { string UserName = _userInfoCookies["UserName"].ToString(); } MvcWebGrid.Models.User obj = new MvcWebGrid.Models.User(); if (Session["User"] != null) { obj = (MvcWebGrid.Models.User)Session["User"]; foreach (var item in obj.Previleges) { switch (item) { case "Add": ViewData["Add"] = true; break; case "Edit": ViewData["Edit"] = true; break; case "Del": ViewData["Del"] = false; break; case "View": ViewData["View"] = true; break; } } if (Request.Form["btnAdd"] != null) { } if (Request.Form["btnDel"] != null) { } if (Request.Form["btnView"] != null) { } } return(View()); }
public ActionResult JsonGrid() { var books = BookOrderRepo.GetBookOrderRepo().Select(r => r.book).ToList(); ViewBag.RadioButtonValues = BookOrderRepo.GetBookOrderRepo().Select(r => r.book).ToList(); List <Employee> lstemp = new List <Employee>(); Employee objemp = new Employee(); IEnumerable <Employee> ietemp = EmployeeRepo.GetEmployees(); lstemp = (List <Employee>)ietemp; //StringBuilder sbHTML = new StringBuilder(); //PropertyInfo[] propertyInfos; //propertyInfos = typeof(Employee).GetProperties(BindingFlags.Public | // BindingFlags.Static); //foreach (var prop in lstemp.GetType().GetProperties()) //{ // sbHTML.Append(prop.Name); // sbHTML.Append("<br>"); //} //for (int i = 0; i < lstemp.Count; i++) //{ // foreach (PropertyInfo Property in lstemp[i].GetType().GetProperties()) // { // sbHTML.Append(Property.GetValue(lstemp[i], null)); // } //} //string str = sbHTML.ToString(); // var employeeValues = GetPropertyValues(lstemp); return(View(lstemp)); }
private void DeleteSelectedButton_Click(object sender, EventArgs e) { var checkedEmployees = new List <Employee>(); foreach (var checkedEmployeeItem in EmployeeListBox.CheckedItems) { checkedEmployees.Add(EmployeeRepo.GetEmployeeByOib(checkedEmployeeItem.ToString().GetOib())); } if (checkedEmployees.Count == 0) { return; } var confirmDeleteEmployee = new ConfirmForm(); confirmDeleteEmployee.ShowDialog(); if (!confirmDeleteEmployee.IsConfirmed) { return; } foreach (var employee in checkedEmployees) { TryDelete(employee); } RefreshEmployeesListBox(); }
public HttpResponseMessage GetForEmptyRecord() { var employees = EmployeeRepo.GetEmployees_emptyRecord(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, employees); return(response); }
public void TestMethod6() { EmployeeRepo employeeRepo = new EmployeeRepo(); bool success = employeeRepo.GetStatsByGender(); Assert.IsTrue(success); }
public ManageEmployeeForm(Login l) { InitializeComponent(); this.l = l; er = new EmployeeRepo(); lr = new LoginRepo(); }
public void CheckDBConnection() { EmployeeRepo repo = new EmployeeRepo(); bool Check = repo.CheckDBConnection(); bool result = true; Assert.AreEqual(result, Check); }
// GET: User public ActionResult Index() { ViewBag.Employee = new SelectList(EmployeeRepo.Get(), "FullName", "FullName"); ViewBag.Role = new SelectList(RoleRepo.Get(), "Name", "Name"); ViewBag.Company = new SelectList(CompanyRepo.Get(), "Name", "Name"); return(View(UserRepo.Get())); }
public void RetriveData_whenQueryGiven() { EmployeeRepo retrive = new EmployeeRepo(); int retrives = retrive.GetAllEmployee(); int result = 13; Assert.AreEqual(retrives, result); }
private void AddEmployeesToProject() { var employeesToUncheck = new List <string>(); foreach (var employeeOib in _checkedEmployeesOibList) { if (RelationProjectEmployeeRepo.IsEmployeeOnProject(employeeOib, OldName)) { continue; } var addHours = new AddHoursForm(NameTextBox.Text, EmployeeRepo.GetEmployeeByOib(employeeOib).Name, false); addHours.ShowDialog(); if (addHours.HoursToAdd == 0) { var hoursError = new ErrorForm( $"Employee {EmployeeRepo.GetEmployeeByOib(employeeOib).Name} could not be added!\nAn employee cannot work 0 hours on a project!"); hoursError.ShowDialog(); employeesToUncheck.Add(employeeOib); continue; } RelationProjectEmployeeRepo.TryAdd(OldName, employeeOib, addHours.HoursToAdd); } UncheckEmployees(employeesToUncheck); }
public void GivenEmployeeNames_WhenUpdateSalary_ThenReturnExpectedSumSalary() { int expected = 700000; EmployeeRepo emprepo = new EmployeeRepo(); int sum = emprepo.getAggrigateSumSalary(); Assert.AreEqual(expected, sum); }
public void GivenMultipleEmployeeDetails_AddPayrollDetails_UsingThread() { EmployeeRepo repo = new EmployeeRepo(); List <EmployeeModel> employees = new List <EmployeeModel>() { new EmployeeModel() { Name = "Terrisa", PhoneNumber = "7775568964", Address = "SA", Gender = 'F', BasicPay = 5500, Deductions = 500, IncomeTax = 300 }, new EmployeeModel() { Name = "Joe", PhoneNumber = "7788968964", Address = "LA", Gender = 'M', BasicPay = 8000, Deductions = 1000, IncomeTax = 500 }, new EmployeeModel() { Name = "Abc", PhoneNumber = "7456768964", Address = "PA", Gender = 'M', BasicPay = 7000, Deductions = 1500, IncomeTax = 500 } }; DateTime startTime = DateTime.Now; foreach (EmployeeModel employee in employees) { Task Thread = new Task(() => { repo.AddEmployeeToPayroll(employee); Console.WriteLine("Employee added : " + employee.Name); }); Thread.Start(); } Console.WriteLine("Total number of employees : " + employees.Count); DateTime stopTime = DateTime.Now; Console.WriteLine("Duration with thread : " + (stopTime - startTime)); }
public void GivenEmployeeNames_WhenAvgSalary_ThenReturnExpectedAvgSalary() { int expected = 341666; EmployeeRepo emprepo = new EmployeeRepo(); int avg = emprepo.getAvragSalary(); Assert.AreEqual(expected, avg); }
public HttpResponseMessage InvalidEmployee(int employee_id) { HttpResponseMessage response = null; try { if (employee_id != 0) { Employee existinginstance = EmployeeRepo.GetEmployeeById(employee_id); if (existinginstance != null) { EmployeeRepo.InactiveEmployee(existinginstance); response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_001", "Success", "Employee accounts closed!")); } else { response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_403", "Invalid Employee ID", "Invalid Employee ID")); } } else { response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_102", "Invalid Employee ID", "Please check input Json")); } } catch (Exception exception) { Debug.WriteLine(exception.Message); Debug.WriteLine(exception.GetBaseException()); response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_101", "Application Error", exception.Message)); } return(response); }
public void GivenEmployeeNames_WhenMinSalary_ThenReturnExpectedMinSalary() { int expected = 100000; EmployeeRepo emprepo = new EmployeeRepo(); int min = emprepo.getMinSalary(); Assert.AreEqual(expected, min); }
public void AddMultiple_Record() { EmployeeRepo payrollRepo = new EmployeeRepo(); EmployeeModel employeeModel = new EmployeeModel { Id = 159, name = "Pratibha", basic_pay = 804000, start_Date = new DateTime(2020, 01, 04), gender = 'F', phoneNumber = "9995676655", department = "Finance", address = "Mumbai", deduction = 6500, taxable = 9500, netpay = 9760, income_tax = 12000.00 }; DateTime startTimes = DateTime.Now; payrollRepo.AddRecord(employeeModel); DateTime endTimes = DateTime.Now; Console.WriteLine("Duration without thread = " + (endTimes - startTimes)); }
public HttpResponseMessage Login(User user) { HttpResponseMessage response = null; try { user.password = EncryptPassword.CalculateHash(user.password); Dictionary <string, object> resultSet = new Dictionary <string, object>(); if (!CommonRepo.Login(user)) { response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_301", "Invalid Username or Password", "Invalid Username or Password")); } else { int user_id = CommonRepo.GetUserID(user); Role role = CommonRepo.GetUserRole(user_id); EmployeeModel employee = EmployeeRepo.GetEmployeeDetailsByUserId(user_id); resultSet.Add("employee_id", employee.id); resultSet.Add("user_id", user_id); resultSet.Add("UserName", employee.first_name + employee.last_name); resultSet.Add("role_name", role.role_name); resultSet.Add("role_id", role.id); resultSet.Add("gender", employee.gender); response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_001", "Success", resultSet)); } } catch (Exception exception) { Debug.WriteLine(exception.Message); Debug.WriteLine(exception.GetBaseException()); response = Request.CreateResponse(HttpStatusCode.OK, exception.Message); } return(response); }
public ActionResult ChangePassword(UserAdminVM model) { EmployeeRepo eRepo = new EmployeeRepo(); if (string.IsNullOrWhiteSpace(model.password1)) { ModelState.AddModelError("password1", "Please enter your current password"); } if (string.IsNullOrWhiteSpace(model.password2)) { ModelState.AddModelError("password2", "Please enter a new password"); } var userManager = HttpContext.GetOwinContext().GetUserManager <UserManager <AppUser> >(); Models.AppUser user = userManager.Find(model.NewUser.UserName, model.password1); if (user == null || user.Id.ToString() != model.NewUser.EmployeeID) { ModelState.AddModelError("password1", "incorrect password"); } if (ModelState.IsValid) { userManager.ChangePassword(model.NewUser.EmployeeID, model.password1, model.password2); return(RedirectToAction("index", "home")); } return(View("ChangePassword", model)); }
public async Task ReadAllAsync_ShouldReturnAllEmployees() { var employees = new List <Employee> { new Employee { Id = 1, EmployeeId = "21-12344", FirstName = "xyz", LastName = "abc", Department = "IT", Salary = 20000 }, new Employee { Id = 2, EmployeeId = "12-12354", FirstName = "ABC", LastName = "XYZ", Department = "HR", Salary = 15000 } }; var mockSet = new Mock <DbSet <Employee> >() .SetupData(employees); var mockContext = new Mock <EmployeeContext>(); mockContext.Setup(x => x.Employees).Returns(mockSet.Object); var employeeRepo = new EmployeeRepo(mockContext.Object); var response = await employeeRepo.ReadAllAsync(); Assert.AreEqual(2, response.Count()); Assert.AreEqual("12-12354", response.ElementAt(1).EmployeeId); Assert.IsInstanceOfType(response, typeof(List <Employee>)); }
public void UpdateTestA() { InitializeDatabase(new HardcodedDataV2()); var emp = new EmployeeModel() { Id = Guid.Parse("b0b02cd9-0ef0-40ef-922d-5632ca76f25c"), Gender = Gender.Male, Salary = 1000.00, DateOfBirth = new DateTime(1965, 12, 31), DepartmentModelId = Guid.Parse("e244600a-a289-40f8-976d-e4a5a6f91edd"), FullName = "FullName Cc" }; IEmployeeRepo _employeeRepo = new EmployeeRepo(); _employeeRepo.Update(emp); using (var db = new ApplicationDataContext()) { Assert.Equal(7, db.EmployeeModels.Count()); var changedRecord = db.EmployeeModels.FirstOrDefault(e => e.Id == Guid.Parse("b0b02cd9-0ef0-40ef-922d-5632ca76f25c")); Assert.Equal(Gender.Male, changedRecord.Gender); Assert.Equal(1000.00, changedRecord.Salary); Assert.Equal(new DateTime(1965, 12, 31), changedRecord.DateOfBirth); Assert.Equal("FullName Cc", changedRecord.FullName); } }
public void TestMethod4() { EmployeeRepo employeeRepo = new EmployeeRepo(); bool success = employeeRepo.GetEmployeeByName("Terisa"); Assert.IsTrue(success); }