public async Task <EmployeeDomain> GetById(int Id) { try { if (!ModelState.IsValid) { BadRequest(ModelState); } EmployeeDomain model = new EmployeeDomain(); var get = await _repo.GetById(Id); model = new EmployeeDomain { EmpId = model.EmpId, FirstName = model.FirstName, LastName = model.LastName, Address = model.Address, IsActive = model.IsActive, IsDelete = model.IsDelete, CreateOn = model.CreateOn }; return(get); } catch (Exception ex) { return(null); } }
public async Task <EmployeeDomain> Update(EmployeeDomain employeeDomain) { try { if (ModelState.IsValid) { BadRequest(ModelState); } var model = await _repo.GetById(employeeDomain.EmpId); if (model != null) { model.FirstName = employeeDomain.FirstName; model.LastName = employeeDomain.LastName; model.Address = employeeDomain.Address; await _repo.Update(model); } return(model); } catch (Exception ex) { return(null); } }
public void getCalculatedSalaryByEmployee_WithEmployeeMonthlySalary_ReturnMonthlySalaryX12() { // Arrange List <EmployeeDTO> employees = new List <EmployeeDTO>() { new EmployeeDTO() { id = 2, name = "Pedro", contractTypeName = "MonthlySalaryEmployee", roleId = 1, roleName = "Contractor", roleDescription = "", hourlySalary = 50000, monthlySalary = 400000 } }; EmployeeDomain domain = new EmployeeDomain(); SalaryFactory factory = new ConcreteSalaryFactory(); // Act var calculatedEmployeeSalary = domain.getCalculatedSalaryByEmployee(employees, factory).ToList(); decimal actual = calculatedEmployeeSalary[0].AnnualSalary; // Assert decimal expected = 4800000; Assert.AreEqual(expected, actual); }
public async Task <EmployeeDomain> Delete(EmployeeDomain employee) { var result = _dbConContext.Employees.Update(employee); await _dbConContext.SaveChangesAsync(); return(result.Entity); }
public string GetEmployeeById(int Id) { EmployeeDomain employee = _employeeService.GetEmployeeById(Id); EmployeeDTO employeeDTO = DomainToDTOMapper(employee); return(JsonConvert.SerializeObject(employeeDTO)); }
public async Task <EmployeeDomain> Create(EmployeeDomain employee) { var result = await _dbConContext.Employees.AddAsync(employee); await _dbConContext.SaveChangesAsync(); return(result.Entity); }
static void Main(string[] args) { int choice; EmployeeDomain emp = new EmployeeDomain(); BusinessUnitDomain unit = new BusinessUnitDomain(); EmployeeLeaveDomain leave = new EmployeeLeaveDomain(); AssignProjectDomain assign = new AssignProjectDomain(); ProjectDomain project = new ProjectDomain(); do { Console.WriteLine("Enter Choice:"); choice = Convert.ToInt32(Console.ReadLine()); switch (choice) { case 1: emp.addEmployees(); break; case 2: emp.deleteEmployees(); break; case 3: emp.updateEmployees(); break; case 4: unit.addUnits(); break; case 5: unit.updateUnits(); break; case 6: project.addProjects(); break; case 7: leave.addLeave(); break; case 8: leave.deleteLeave(); break; case 9: assign.assignProject(); break; default: Console.WriteLine("Exit"); break; } } while (choice != 10); }
EmployeeDTO DomainToDTOMapper(EmployeeDomain employee) { var employeeDTO = new EmployeeDTO(); employeeDTO.EmpId = employee.EmpId; employeeDTO.EmpName = employee.EmpName; employeeDTO.EmpAge = employee.EmpAge; employeeDTO.EmpEmail = employee.EmpEmail; employeeDTO.EmpSalary = employee.EmpSalary; return(employeeDTO); }
public IHttpActionResult Get(int id) { try { var employee = new EmployeeDomain().getEmployeeById(id); return(Ok(employee)); } catch (Exception ex) { return(InternalServerError(ex)); } }
static void Main(string[] args) { Console.WriteLine("========== WelCome TO Business Information =========="); int choice; EmployeeDomain employeeDomain = new EmployeeDomain(); ProjectDomain projectDomain = new ProjectDomain(); do { Console.WriteLine("\n======= Menu ======="); Console.WriteLine("1.Add Employee"); Console.WriteLine("2.View Employees"); Console.WriteLine("3.Add Project"); Console.WriteLine("4.View Projects"); Console.WriteLine("0.Exit"); Console.Write("\nEnter Your choice : "); choice = Convert.ToInt32(Console.ReadLine()); switch (choice) { case 1: Console.WriteLine("\n====== Add Employee ====="); employeeDomain.addEmolpyee(); break; case 2: Console.WriteLine("\n====== View Employees ====="); employeeDomain.ViewEmployee(); break; case 3: Console.WriteLine("\n====== Add Project Details ====="); projectDomain.addProject(); break; case 4: Console.WriteLine("\n====== View All Project Details ====="); projectDomain.viewAllProject(); break; case 0: return; default: Console.WriteLine("Invalid choice"); break; } } while (i > -1); }
public async Task <IActionResult> Add(EmployeeDomain employeeDomain) { if (!ModelState.IsValid) { BadRequest(ModelState); } var saveData = new EmployeeDomain { FirstName = employeeDomain.FirstName, LastName = employeeDomain.LastName, Address = employeeDomain.Address, IsActive = true, IsDelete = false, CreateOn = DateTime.Now }; if (saveData != null) { await _repo.Create(saveData); } return(Ok(employeeDomain)); }
public async Task <EmployeeDomain> Delete(EmployeeDomain employee) { try { if (ModelState.IsValid) { BadRequest(ModelState); } var model = await _repo.GetById(employee.EmpId); if (model != null) { model.IsDelete = true; model.IsActive = false; await _repo.Delete(model); } return(model); } catch (Exception ex) { return(null); } }
/// <summary> /// Construtor referente ao controller do Módulo Empresa /// </summary> public CompanyController(SysQueirozContext context) { employeeDomain = new EmployeeDomain(context); }
static void Main(string[] args) { Console.WriteLine("Welcome to Hospital List Application"); bool showMenu = true; AdmitDomain admitDomain = new AdmitDomain(); AppointmentDomain appointmentDomain = new AppointmentDomain(); BedDomain bedDomain = new BedDomain(); DepartmentDomain departmentDomain = new DepartmentDomain(); DoctorDomain doctorDomain = new DoctorDomain(); EmployeeDomain employeeDomain = new EmployeeDomain(); MedicineDomain medicineDomain = new MedicineDomain(); NursingDomain nursingDomain = new NursingDomain(); PatientDomain patientDomain = new PatientDomain(); PrescribeMedicineDomain prescribeMedicineDomain = new PrescribeMedicineDomain(); PrescriptionDomain prescriptionDomain = new PrescriptionDomain(); ProblemDomain problemDomain = new ProblemDomain(); TreatmentDomain treatmentDomain = new TreatmentDomain(); while (showMenu) { Console.Clear(); Console.WriteLine("Choose an option:"); Console.WriteLine("1) Appointment"); Console.WriteLine("2) Admit"); Console.WriteLine("3) List Admits"); Console.WriteLine("4) Exit"); Console.Write("\r\nSelect an option: "); switch (Console.ReadLine().Trim()) { case "1": { Appointment appointment = new Appointment(); Patient patient = new Patient(); Console.Write("Enter Name : "); patient.PatientName = Console.ReadLine().Trim(); Console.Write("Enter Age : "); patient.Age = Convert.ToInt32(Console.ReadLine().Trim()); Console.Write("Enter Gender : "); patient.Gender = Convert.ToInt32(Console.ReadLine().Trim()); Console.Write("Enter PhoneNo : "); patient.PhoneNo = Convert.ToInt64(Console.ReadLine().Trim()); Console.Write("Enter Address : "); patient.Address = Console.ReadLine().Trim(); patientDomain.AddPatient(patient); Console.Write("Patient Added"); appointment.PatientId = patient.PatientId; Console.WriteLine("No Name Speciality"); foreach (Doctor doctor in doctorDomain.GetDoctors()) { Console.WriteLine($"{doctor.DoctorId} {doctor.DoctorName} {doctor.Speciality}"); } Console.Write("Select Doctor by No : "); appointment.DoctorId = Convert.ToInt32(Console.ReadLine().Trim()); Console.WriteLine("No ProblemType Description"); foreach (Problem problem in problemDomain.GetProblem()) { Console.WriteLine($"{problem.ProblemId} {problem.ProblemType} {problem.Description}"); } Console.Write("Select Problem by No : "); appointment.ProblemId = Convert.ToInt32(Console.ReadLine().Trim()); Console.Write("Enter Appointment DateTime : "); appointment.DateTime = Convert.ToDateTime(Console.ReadLine().Trim()).Date; appointmentDomain.AddApointment(appointment); Console.ReadLine(); break; } case "2": { Admit admit = new Admit(); Console.WriteLine("No Name PhoneNo"); foreach (Patient patient in patientDomain.GetPatients()) { Console.WriteLine($"{patient.PatientId} {patient.PatientName} {patient.PhoneNo}"); } Console.Write("Select Patient by No : "); admit.PatientId = Convert.ToInt32(Console.ReadLine().Trim()); Console.WriteLine("No Name Speciality"); foreach (Doctor doctor in doctorDomain.GetDoctors()) { Console.WriteLine($"{doctor.DoctorId} {doctor.DoctorName} {doctor.Speciality}"); } Console.Write("Select Doctor by No : "); admit.DoctorId = Convert.ToInt32(Console.ReadLine().Trim()); Console.WriteLine("No Department Name"); foreach (Department department in departmentDomain.GetDepartments()) { Console.WriteLine($"{department.DepartmentId} {department.DepartmentName}"); } Console.Write("Select Department by No : "); admit.DepartmentId = Convert.ToInt32(Console.ReadLine().Trim()); Console.WriteLine("No BedNo RoomNo"); foreach (Bed bed in bedDomain.GetBeds()) { Console.WriteLine($"{bed.BedId} {bed.BedNo} {bed.RoomNo}"); } Console.Write("Select Bed by No : "); admit.DepartmentId = Convert.ToInt32(Console.ReadLine().Trim()); Console.Write("Enter Admit Start DateTime : "); admit.StartDate = Convert.ToDateTime(Console.ReadLine().Trim()).Date; admitDomain.AddAdmit(admit); Console.ReadLine(); break; } case "3": { Console.WriteLine("No Patient Name BedNo Doctor Name StartDate"); foreach (Admit admit in admitDomain.GetAdmits()) { Console.WriteLine($"{admit.AdmitId} {admit.Patient.PatientName} {admit.Bed.BedNo} {admit.Doctor.DoctorName} {admit.StartDate}"); } Console.ReadLine(); break; } case "4": showMenu = false; break; default: Console.WriteLine("please enter correct option"); break; } } }
static void Main(string[] args) { Console.WriteLine("Welcome to Techie Company"); bool showMenu = true; BusinessUnitDomain businessUnitDomain = new BusinessUnitDomain(); EmployeeDomain employeeDomain = new EmployeeDomain(); EmployeeLeaveDomain employeeLeaveDomain = new EmployeeLeaveDomain(); EmployeeProjectDomain employeeProjectDomain = new EmployeeProjectDomain(); ProjectDomain projectDomain = new ProjectDomain(); while (showMenu) { Console.Clear(); Console.WriteLine("Choose an option:"); Console.WriteLine("1) Add Employee"); Console.WriteLine("2) Add Employee Leave"); Console.WriteLine("3) Add Employee Project"); Console.WriteLine("4) Add Project"); Console.WriteLine("5) List Project"); Console.WriteLine("6) Exit"); Console.Write("\r\nSelect an option: "); switch (Console.ReadLine().Trim()) { case "1": { Employees employee = new Employees(); Console.Write("Enter Name : "); employee.EmployeeName = Console.ReadLine().Trim(); Console.Write("Enter Phone No : "); employee.PhoneNo = Convert.ToInt64(Console.ReadLine().Trim()); Console.Write("Enter Email : "); employee.Email = Console.ReadLine().Trim(); Console.Write("Enter Employee Type : "); employee.EmployeeType = Convert.ToInt32(Console.ReadLine().Trim()); Console.WriteLine("No Name"); foreach (BusinessUnits businessUnit in businessUnitDomain.GetBusinessUnits()) { Console.WriteLine($"{businessUnit.BusinessUnitId} {businessUnit.BusinessUnitName}"); } Console.Write("Select Business Unit by No : "); employee.BusinessUnitId = Convert.ToInt32(Console.ReadLine().Trim()); employeeDomain.AddEmployee(employee); Console.Write("Employee Added"); Console.ReadLine(); break; } case "2": { EmployeeLeaves employeeLeave = new EmployeeLeaves(); EmployeeName: Console.Write("Enter Employee Name : "); var Employees = employeeDomain.GetByEmployeeName(Console.ReadLine().Trim()); Console.WriteLine("No Employee Name EmployeeType PhoneNo"); foreach (Employees employee in Employees) { Console.WriteLine($"{employee.EmployeeId} {employee.EmployeeName} {employee.EmployeeType} {employee.PhoneNo}"); } Console.WriteLine("You want to Search Again then enter '0' or Enter Employee No?"); int employeeId = Convert.ToInt32(Console.ReadLine().Trim()); if (employeeId == 0) { goto EmployeeName; } employeeLeave.EmployeeId = employeeId; Console.Write("Enter Start Date : "); employeeLeave.StartDate = Convert.ToDateTime(Console.ReadLine().Trim()); Console.Write("Enter End Date : "); employeeLeave.EndDate = Convert.ToDateTime(Console.ReadLine().Trim()); employeeLeaveDomain.AddEmployeeLeave(employeeLeave); Console.Write("Employee Leave is Created"); break; } case "3": { EmployeeProjects employeeProject = new EmployeeProjects(); EmployeeName: Console.Write("Enter Employee Name : "); List <Employees> Employees = employeeDomain.GetByEmployeeName(Console.ReadLine().Trim()); Console.WriteLine("No Employee Name EmployeeType PhoneNo"); foreach (Employees employee in Employees) { Console.WriteLine($"{employee.EmployeeId} {employee.EmployeeName} {employee.EmployeeType} {employee.PhoneNo}"); } Console.WriteLine("You want to Search Again then enter '0' or Enter Employee No?"); int employeeId = Convert.ToInt32(Console.ReadLine().Trim()); if (employeeId == 0) { goto EmployeeName; } employeeProject.EmployeeId = employeeId; Console.WriteLine("No Project Name"); foreach (Projects project in projectDomain.GetByBusinessUnit(Employees.Find(t => t.EmployeeId == employeeId).BusinessUnitId)) { Console.WriteLine($"{project.ProjectId} {project.ProjectName}"); } Console.Write("Select Project by No : "); employeeProject.ProjectId = Convert.ToInt32(Console.ReadLine().Trim()); employeeProjectDomain.AddEmployeeProject(employeeProject); Console.Write("Project is Assign to Employee"); break; } case "4": { Projects project = new Projects(); Console.Write("Enter Name : "); project.ProjectName = Console.ReadLine().Trim(); Console.Write("Enter Budget : "); project.Budget = Convert.ToInt32(Console.ReadLine().Trim()); Console.Write("Enter Start Date : "); project.StartDate = Convert.ToDateTime(Console.ReadLine().Trim()); Console.Write("Enter Deadline Date : "); project.DeadLine = Convert.ToDateTime(Console.ReadLine().Trim()); Console.WriteLine("No Name"); foreach (BusinessUnits businessUnit in businessUnitDomain.GetBusinessUnits()) { Console.WriteLine($"{businessUnit.BusinessUnitId} {businessUnit.BusinessUnitName}"); } Console.Write("Select Business Unit by No : "); project.BusinessUnitId = Convert.ToInt32(Console.ReadLine().Trim()); EmployeeName: Console.Write("Enter Employee Name : "); List <Employees> Employees = employeeDomain.GetByEmployeeName(Console.ReadLine().Trim()); Console.WriteLine("No Employee Name EmployeeType PhoneNo"); foreach (Employees employee in Employees) { Console.WriteLine($"{employee.EmployeeId} {employee.EmployeeName} {employee.EmployeeType} {employee.PhoneNo}"); } Console.WriteLine("You want to Search Again then enter '0' or Enter Employee No?"); int employeeId = Convert.ToInt32(Console.ReadLine().Trim()); if (employeeId == 0) { goto EmployeeName; } project.ProjectManagerId = employeeId; project.Status = 10; projectDomain.AddProject(project); Console.Write("ManufactureUnit Added"); Console.ReadLine(); break; } case "5": { Console.WriteLine("No Project Name BusinessUnit Project Manager Start Date DeadLine"); foreach (Projects project in projectDomain.GetProjects()) { Console.WriteLine($"{project.ProjectId} {project.ProjectName} {project.BusinessUnit.BusinessUnitName} {project.ProjectManager.EmployeeName} {project.StartDate} {project.DeadLine}"); } Console.ReadLine(); break; } case "6": { showMenu = false; break; } default: Console.WriteLine("please enter correct option"); break; } } }