コード例 #1
0
 public ActionResult DeleteConfirmed(int id)
 {
     EmployeeService service = new EmployeeService();
     Employee model = service.GetEmployeeByID(new Employee() { Id = id });
     service.Remove(model);
     return RedirectToAction("Index");
 }
コード例 #2
0
 //
 // GET: /Employee/Details/5
 public ViewResult Details(int id)
 {
     EmployeeService service = new EmployeeService();
     Employee model = service.GetEmployeeByID(new Employee() { Id = id });
     model.ActionOperationType = EActionOperationType.Details;
     return View("Create",model);
 }
コード例 #3
0
ファイル: EmployeeWeekBuilder.cs プロジェクト: 5509850/baumax
        public EmployeeWeekBuilder()
        {
            _employeeservice = ServerEnvironment.EmployeeService as EmployeeService;

            if (_employeeservice == null)
                throw new ArgumentNullException();
        }
コード例 #4
0
 //
 // GET: /Employee/Edit/5
 public ActionResult Edit(int id)
 {
     EmployeeService service = new EmployeeService();
     Employee model = service.GetEmployeeByID(new Employee() { Id = id });
     model.ActionOperationType = EActionOperationType.Edit;
     this.LoadEditViewBag(model);
     return View("Create",model);
 }
コード例 #5
0
ファイル: Form1.cs プロジェクト: ThomasDeboben/tsdn
        private void buttonCreateEmployee_Click(object sender, EventArgs e)
        {
            var employee = new Employee();
            employee.Name = "thomas";

            var employeeService = new EmployeeService();
            employeeService.Create(employee);
        }
コード例 #6
0
ファイル: ServiceContext.cs プロジェクト: dalinhuang/ACS
 public EmployeeService getEmployeeService()
 {
     if (employeeService == null)
     {
         employeeService = new EmployeeServiceImpl();
     }
     return employeeService;
 }
コード例 #7
0
 /// <summary>
 /// 实现控制反转
 /// </summary>
 /// <param name="moduleFunctionRepos"></param>
 public Admin_EmployeeController(IEmployeeRepository employeeRepos, IRoleRepository rolerepos, ICustomerRepository customerrepos, ecoBio.Wms.Backstage.Repositories.IDynamicToken tokenRepos,
       ecoBio.Wms.Backstage.Repositories.IDepartmentListRepository departmentListRepos)
 {
     _roleservice = new RoleService(rolerepos);
     _employeeservice = new EmployeeService(employeeRepos);
     _custoimerservice = new CustomerService(customerrepos);
     _tokenRepos = new Service.Management.DynamicTokenService(tokenRepos);
     _departmentListRepos = new Service.Management.DepartmentListService(departmentListRepos);
 }
コード例 #8
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (validator1.Validate())
            {
                if (employee != null && employee.Id > 0)//edit
                {
                    employee.Address = txtAddress.Text;
                    employee.Description = txtDescription.Text;
                    employee.Email = txtEmail.Text;
                    employee.FullName = txtFullName.Text;
                    employee.MobilePhone = txtMobilePhone.Text;
                    employee.NickName = txtNickName.Text;
                    employee.Code = txtEmployeeCode.Text;
                    employee.Type = cbType.SelectedValue != null ? (short)cbType.SelectedValue : (short)0;

                    EmployeeService employeeService = new EmployeeService();
                    bool result = employeeService.UpdateEmployee(employee);
                    if (result)
                    {
                        MessageBox.Show("Thông tin nhân viên đã được cập nhật vào hệ thống");
                        ((EmployeeList)this.CallFromUserControll).loadEmployeeList();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else//add new
                {
                    employee = new Employee
                    {
                        Address = txtAddress.Text,
                        Description = txtDescription.Text,
                        Email = txtEmail.Text,
                        FullName = txtFullName.Text,
                        MobilePhone = txtMobilePhone.Text,
                        NickName = txtNickName.Text,
                        Code = txtEmployeeCode.Text,
                        Type = cbType.SelectedValue != null ? (short)cbType.SelectedValue : (short)0
                    };
                    EmployeeService employeeService = new EmployeeService();
                    bool result = employeeService.AddEmployee(employee);
                    if (result)
                    {
                        MessageBox.Show("Nhân viên đã được thêm mới vào hệ thống");
                        ((EmployeeList)this.CallFromUserControll).loadEmployeeList();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
コード例 #9
0
        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)));
        }
コード例 #10
0
 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);
 }
コード例 #11
0
        public static IEnumerable<SelectListItem> FillddlEmployee()
        {
            var service = new EmployeeService();
            var employees = service.GetAll();
            var listitems = employees.Select(x =>

                new SelectListItem
                {
                    Text = x.EmployeeName,
                    Value = x.Id.ToString()
                });
            return listitems;
        }
コード例 #12
0
        public void loadCustomerList()
        {
            EmployeeService service = new EmployeeService();
            List<Employee> salers = service.GetEmployees();
            salers.Add(new Employee() { Id = 0, FullName = "Tất cả" });
            salers = salers.OrderBy(x => x.Id).ToList();
            cmbSaler.DataSource = salers;
            cmbSaler.DisplayMember = "FullName";
            cmbSaler.ValueMember = "Id";

            CustomerService customerService = new CustomerService();
            customers = customerService.GetCustomers();
            setUpDataGrid(customers);
        }
コード例 #13
0
        public void ShouldGetAllApprovers()
        {
            OrdersManagementDataSet ds = new OrdersManagementDataSet();
            ds.Employees.AddEmployeesRow("jblack", "Black", "Joe");
            ds.Employees.AddEmployeesRow("a-jdoe", "Doe", "John");
            ds.AcceptChanges();
            EmployeeService employeeService = new EmployeeService(ds);

            List<Employee> employees = new List<Employee>(employeeService.AllApprovers);

            Assert.IsNotNull(employees);
            Assert.AreEqual(1, employees.Count);
            Assert.AreEqual("a-jdoe", employees[0].EmployeeId);
            Assert.AreEqual("Doe", employees[0].LastName);
        }
コード例 #14
0
        public void Should_Return_All_Employees_Not_Deleted()
        {
            //Arrange
            var employeesNotDeleted = EmployeeDummies.CreateListOfEmployees().Where(e => !e.IsDeleted);
            var employeeRepositoryMock = new Mock<IEmployeeRepository>();
            employeeRepositoryMock.Setup(x => x.GetAllEmployeesNotDeleted()).Returns(employeesNotDeleted);

            var employeeService = new EmployeeService(employeeRepositoryMock.Object, new StubUnitOfWork());

            //Act
            var employees = employeeService.ListEmployeesNotDeleted();

            //Assert
            employeeRepositoryMock.VerifyAll();
            Assert.IsFalse(employees.Any(e => e.IsDeleted));
        }
コード例 #15
0
        public void Should_Return_All_Employees_Even_The_Deleted_Ones()
        {
            //Arrange
            var employeesList = EmployeeDummies.CreateListOfEmployees();
            var employeeRepositoryMock = new Mock<IEmployeeRepository>();
            employeeRepositoryMock.Setup(x => x.GetAll()).Returns(employeesList);

            var employeeService = new EmployeeService(employeeRepositoryMock.Object, new StubUnitOfWork());

            //Act
            var employees = employeeService.ListEmployee();

            //Assert
            employeeRepositoryMock.VerifyAll();
            Assert.IsTrue(employees.Any(e => e.IsDeleted));
        }
コード例 #16
0
        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");
        }
コード例 #17
0
 void LoadEmployees()
 {
     EmployeeService employeeService = new EmployeeService();
     employees = employeeService.GetEmployees();
     Employee e = new Employee
     {
         Id = 0,
         FullName = "Tất cả"
     };
     employees.Add(e);
     employees = employees.OrderBy(el => el.Id).ToList();
     if (employees != null)
     {
         cbmEmployees.DataSource = employees;
         cbmEmployees.DisplayMember = "FullName";
         cbmEmployees.ValueMember = "Id";
     }
 }
コード例 #18
0
        public void Given_A_Request_To_List_All_Active_Users_From_The_Company_Who_Is_Requesting_When_Requesting_Then_Should_Return_All_Active_Users_From_That_Company()
        {
            //Arrange
            var companyRequesting = CompanyDummies.CreatePortofinoCompany();
            var employeesNotDeletedFromCompany = EmployeeDummies.CreateListOfEmployees().Where(e => !e.IsDeleted && e.Company.Id == companyRequesting.Id);

            var employeeRepositoryMock = new Mock<IEmployeeRepository>();

            employeeRepositoryMock.Setup(x => x.GetAllEmployeesFromCompanyNotDeleted(companyRequesting.Id)).Returns(employeesNotDeletedFromCompany);

            var employeeService = new EmployeeService(employeeRepositoryMock.Object, new StubUnitOfWork());

            //Act
            var employees = employeeService.ListEmployeesFromCompanyNotDeleted(companyRequesting.Id);

            ////Assert
            employeeRepositoryMock.VerifyAll();
            Assert.IsFalse(employees.Any(e => e.IsDeleted));
            Assert.IsFalse(employees.Any(e => e.Company.Id != companyRequesting.Id));
        }
コード例 #19
0
        public void loadDataForEditEmployee(int employeeId)
        {
            this.Text = "Chỉnh sửa thông tin nhân viên";
            this.btnSave.Text = "Cập nhật";

            EmployeeService employeeService = new EmployeeService();

            employee = employeeService.GetEmployee(employeeId);
            if (employee != null)
            {
                txtAddress.Text = employee.Address ;
                txtDescription.Text = employee.Description;
                txtEmail.Text = employee.Email;
                txtFullName.Text = employee.FullName;
                txtMobilePhone.Text = employee.MobilePhone;
                txtNickName.Text = employee.NickName ;
                txtEmployeeCode.Text = employee.Code;
                cbType.SelectedIndex = (int)employee.Type;
            }
        }
コード例 #20
0
 private void loadSomeData()
 {            
     if (salers == null)
     {
         EmployeeService empls = new EmployeeService();
         salers = empls.GetEmployees();
     }
     if (salers != null)
     {
         cmbSaler.DataSource = salers;
         cmbSaler.DisplayMember = "FullName";
         cmbSaler.ValueMember = "Id";
         if (customer != null)
         {
             cmbSaler.SelectedIndex = salers.FindIndex(su => su.Id == customer.SalerId);
         }
     }
     if (customers == null)
     {
         CustomerService cus = new CustomerService();
         customers = cus.GetCustomers();
     }
 }
コード例 #21
0
 public EmployeesController()
 {
     Service = new EmployeeService();
 }
コード例 #22
0
        //
        // GET: /Employee/
        //[OutputCache(CacheProfile = "Long", VaryByHeader = "X-Requested-With;Accept-Language", Location = OutputCacheLocation.Server)]
        public ActionResult Index(int? page = 1)
        {
            IPagedList<EmployeeViewModel> list = null;

            using (ModelRepository db = new ModelRepository(this._factory.GetDatabaseObject()))
            {
                EmployeeService service = new EmployeeService(db);
                list = service.GetPagedList(this._toViewModel, page ?? 1);
            }

            return View(list);
        }
コード例 #23
0
 public ActionResult Logout(string sessionId)
 {
     EmployeeService.RemoveSession(sessionId);
     return(RedirectToAction("Login", "Home"));
 }
コード例 #24
0
 protected override async Task OnInitializedAsync()
 {
     // If Id value is not supplied in the URL, use the value 1
     Id       = Id ?? "1";
     Employee = await EmployeeService.GetEmployee(int.Parse(Id));
 }
コード例 #25
0
 protected async override Task OnInitializedAsync()
 {
     Id       = Id ?? "1";
     Employee = await EmployeeService.GetEmployee(int.Parse(Id));
 }
コード例 #26
0
        public void CreateNewBookingTest( )
        {
            //Arrange
            BookingService    bs  = new BookingService();
            CustomerService   cs  = new CustomerService();
            EscapeRoomService es  = new EscapeRoomService();
            EmployeeService   ems = new EmployeeService();

            MAPMA_WebClient.CusRef.Customer   cus = cs.GetCustomer("Anorak");
            MAPMA_WebClient.EmpRef.Employee   em  = ems.GetEmployee(1);
            MAPMA_WebClient.EscRef.EscapeRoom er  = es.GetEscapeRoom(1);
            Customer customer = new Customer()
            {
                customerNo = cus.customerNo,
                firstName  = cus.firstName,
                lastName   = cus.lastName,
                mail       = cus.mail,
                password   = cus.password,
                phone      = cus.phone,
                username   = cus.username
            };
            Employee employee = new Employee()
            {
                address    = em.address,
                cityName   = em.cityName,
                employeeID = em.employeeID,
                firstName  = em.firstName,
                lastName   = em.lastName,
                mail       = em.mail,
                phone      = em.phone,
                region     = em.region,
                zipcode    = em.zipcode
            };
            EscapeRoom escapeRoom = new EscapeRoom()
            {
                cleanTime    = er.cleanTime,
                description  = er.description,
                escapeRoomID = er.escapeRoomID,
                maxClearTime = er.maxClearTime,
                name         = er.name,
                price        = er.price,
                rating       = er.rating
            };
            Booking hostBook;
            Booking book = new Booking()
            {
                amountOfPeople = 22,
                bookingTime    = DateTime.Now.TimeOfDay,
                cus            = customer,
                date           = DateTime.Now.AddDays(7.0).Date,
                emp            = employee,
                er             = escapeRoom
            };


            //Act
            bs.CreateBooking(book.emp.employeeID, book.cus.username, book.er.escapeRoomID, book.bookingTime, book.amountOfPeople, book.date);
            hostBook = bs.GetBooking(book.er.escapeRoomID, book.cus.username, book.date);

            //Assert
            Assert.AreEqual(book.date, hostBook.date);
            Assert.AreEqual(book.emp.employeeID, hostBook.emp.employeeID);
            Assert.AreEqual(book.cus.username, hostBook.cus.username);

            bs.DeleteBooking(book.emp.employeeID, book.cus.username, book.er.escapeRoomID, book.bookingTime, book.amountOfPeople, book.date);
        }
コード例 #27
0
        public void AddEmployeeTests()
        {
            var serv = new EmployeeService(new MVCHContext());

            serv.AddNurse(new Nurse
            {
                FirstName     = "Cedrick",
                LastName      = "Sederiosa",
                MiddleInitial = "S.",
                Address       = "3212 Kahel St., Sto. Domingo II, Pampanga",
                City          = "Davao City",
                State         = "Philippines",
                BirthDate     = DateTime.ParseExact("09/02/2000", "mm/dd/yyyy", new CultureInfo("en-PH")),
                Email         = "*****@*****.**",
                PhoneNumber   = "+639495940509",
                Zip           = "8000",
                Degree        = "RN",
                License       = "123"
            });
            serv.AddNurse(new Nurse
            {
                FirstName     = "John",
                LastName      = "Branzuela",
                MiddleInitial = "C.",
                Address       = "Sasa Dose",
                City          = "Davao City",
                State         = "Philippines",
                BirthDate     = DateTime.ParseExact("10/04/1999", "mm/dd/yyyy", new CultureInfo("en-PH")),
                Email         = "*****@*****.**",
                PhoneNumber   = "+63969696969",
                Zip           = "8000",
                Degree        = "LPN",
                License       = "123"
            });
            serv.AddNurse(new Nurse
            {
                FirstName     = "Nathan",
                LastName      = "Naanep",
                MiddleInitial = "G.",
                Address       = "Ilonggo",
                City          = "Koronadal City",
                State         = "Philippines",
                BirthDate     = DateTime.ParseExact("03/25/2000", "mm/dd/yyyy", new CultureInfo("en-PH")),
                Email         = "*****@*****.**",
                PhoneNumber   = "+63969696969",
                Zip           = "8000",
                Degree        = "RN",
                License       = "123"
            });
            serv.AddNurse(new Nurse
            {
                FirstName     = "Mecca",
                LastName      = "Umapas",
                MiddleInitial = "S.",
                Address       = "Surigao",
                City          = "Surigao",
                State         = "Philippines",
                BirthDate     = DateTime.ParseExact("10/30/1999", "mm/dd/yyyy", new CultureInfo("en-PH")),
                Email         = "*****@*****.**",
                PhoneNumber   = "+63969696969",
                Zip           = "8000",
                Degree        = "LPN",
                License       = "123"
            });
            serv.AddStaff(new Staff
            {
                FirstName     = "Yoshi",
                LastName      = "Aizawa",
                MiddleInitial = "M.",
                Address       = "Mintal",
                City          = "Davao City",
                State         = "Japan",
                BirthDate     = DateTime.ParseExact("12/13/1999", "mm/dd/yyyy", new CultureInfo("en-PH")),
                Email         = "*****@*****.**",
                PhoneNumber   = "+63969696969",
                Zip           = "8000",
                JobClassId    = "JOB-000001"
            });
            serv.AddStaff(new Staff
            {
                FirstName     = "Adrian",
                LastName      = "De Guzman",
                MiddleInitial = "A.",
                Address       = "Ilonggo",
                City          = "Tacurong City",
                State         = "Philippines",
                BirthDate     = DateTime.ParseExact("06/08/2000", "mm/dd/yyyy", new CultureInfo("en-PH")),
                Email         = "*****@*****.**",
                PhoneNumber   = "+63969696969",
                Zip           = "8000",
                JobClassId    = "JOB-000001"
            });
            serv.AddStaff(new Staff
            {
                FirstName     = "Abigail",
                LastName      = "M.",
                MiddleInitial = "M.",
                Address       = "3212 Kahel St., Sto. Domingo II, Pampanga",
                City          = "Davao City",
                State         = "Philippines",
                BirthDate     = DateTime.ParseExact("09/02/2000", "mm/dd/yyyy", new CultureInfo("en-PH")),
                Email         = "*****@*****.**",
                PhoneNumber   = "+63969696969",
                Zip           = "8000",
                JobClassId    = "JOB-000001"
            });
            serv.AddTechnician(new Technician
            {
                FirstName     = "Anna",
                LastName      = "O.",
                MiddleInitial = "O.",
                Address       = "3212 Kahel St., Sto. Domingo II, Pampanga",
                City          = "Davao City",
                State         = "Philippines",
                BirthDate     = DateTime.ParseExact("09/02/2000", "mm/dd/yyyy", new CultureInfo("en-PH")),
                Email         = "*****@*****.**",
                PhoneNumber   = "+63969696969",
                Zip           = "8000",
                License       = "123"
            });
            serv.AddTechnician(new Technician
            {
                FirstName     = "Katriana",
                LastName      = "B.",
                MiddleInitial = "B.",
                Address       = "3212 Kahel St., Sto. Domingo II, Pampanga",
                City          = "Davao City",
                State         = "Philippines",
                BirthDate     = DateTime.ParseExact("09/02/2000", "mm/dd/yyyy", new CultureInfo("en-PH")),
                Email         = "*****@*****.**",
                PhoneNumber   = "+63969696969",
                Zip           = "8000",
                License       = "123"
            });
            serv.AddTechnician(new Technician
            {
                FirstName     = "Dexie",
                LastName      = "Badilles",
                MiddleInitial = ".",
                Address       = "Sasa",
                City          = "Davao City",
                State         = "Philippines",
                BirthDate     = DateTime.ParseExact("09/02/2000", "mm/dd/yyyy", new CultureInfo("en-PH")),
                Email         = "*****@*****.**",
                PhoneNumber   = "+63969696969",
                Zip           = "8000",
                License       = "123"
            });
        }
コード例 #28
0
 public SaleController(SaleOrderService saleOrderService, EmployeeService employeeService)
 {
     this.SaleOrderService = saleOrderService;
     this.EmployeeService  = employeeService;
 }
コード例 #29
0
        protected override async Task OnInitializedAsync()
        {
            var num = int.Parse(Id);

            Employee = await EmployeeService.GetEmployeeByIdAsync(num);
        }
コード例 #30
0
 public ManageEmployee()
 {
     employeeService = new EmployeeService();
 }
コード例 #31
0
 public EmployeesController(EmployeeService employeeService
                            , ILogger <EmployeesController> logger)
 {
     _employeeService = employeeService;
     _logger          = logger;
 }
コード例 #32
0
 public ListEmployeesOlderThanCommand(EmployeeService employeeService)
 {
     this.employeeService = employeeService;
 }
 public AddEmployeeCommand(EmployeeService employeeService)
 {
     this.employeeService = employeeService;
 }
コード例 #34
0
        public ActionResult Edit(EmployeeViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return View(viewModel);
            }

            using (ModelRepository db = new ModelRepository(this._factory.GetDatabaseObject()))
            {
                EmployeeService service = new EmployeeService(db);

                var model = service.GetObjectList(x => x.Id == viewModel.Id).FirstOrDefault();

                if (model == null)
                {
                    return RedirectToAction("Index");
                }

                service.Update(this._toBusinessModel(viewModel));

                db.SaveChanges();
            }

            return RedirectToAction("Index");
        }
コード例 #35
0
 public static void SetUp(TestContext testContext)
 {
     ServiceEmployee        = EmployeeService.Instance();
     CompanyService         = new CompanyService();
     GeoLocalizationService = new GeoLocalizationService();
 }
コード例 #36
0
 public void InvoiceServiceSetup()
 {
     service = WindsorPersistenceFixture.Container.Resolve <EmployeeService>();
 }
コード例 #37
0
        protected override async Task OnInitializedAsync()
        {
            EmployeeList = await EmployeeService.GetAll();

            await base.OnInitializedAsync();
        }
コード例 #38
0
 public void InvoiceServiceTeardown()
 {
     service = null;
 }
コード例 #39
0
        static void Main(string[] args)
        {
            #region C# 7 New Features
            Message.PrintTask(Resources.CSharpFeature);

            // Task 1: Invoking and Deconstruct Tuple
            TupleTask task = new TupleTask();
            var(firstName, middleName, lastName) = task.GetData(Constants.FirstName, Constants.MiddleName, Constants.LastName);
            Message.Print(string.Format(Resources.GetFullName, firstName, middleName, lastName));

            // Task 2: Expression Bodied Members
            Student student = new Student(Constants.FirstName);
            student.ShowSkills();
            student.OtherSkill = Skills.AWS.ToString();
            student.ShowOtherSkill();
            student.ShowSkill(2);

            // Updating the skill by index
            student[2] = Skills.Java.ToString();
            student.ShowSkill(2);

            // Task 3: Expando Object
            dynamic dynamicEmployee = new ExpandoObject();

            // Properties of Employee
            Employee employee = new Employee()
            {
                Email  = Constants.Email,
                Name   = Constants.FirstName,
                Salary = Constants.Salary
            };

            dynamicEmployee.Email  = employee.Email;
            dynamicEmployee.Name   = employee.Name;
            dynamicEmployee.Salary = employee.Salary;

            // New Expando Properties
            dynamicEmployee.Address = Constants.Address;
            dynamicEmployee.Age     = Constants.Age;

            // New Expando Method
            dynamicEmployee.GetDetails = new Action(() => { Message.Print(string.Format("\nName: {0}, Age: {1}, Address: {2}", dynamicEmployee.Name, dynamicEmployee.Age, dynamicEmployee.Address)); });

            // Invoking the Expando Method
            dynamicEmployee.GetDetails();

            #endregion

            #region Memory Management

            Message.PrintTask(Resources.MemoryManagement);

            // Task 1: Displays the property value using "using" block
            using (MyClass myClass = new MyClass())
            {
                Message.Print(string.Format(Resources.IntegerResult, myClass.MyInteger));
            }

            // Task 2: Disposing the object using finally block
            MyClass myClassObject = new MyClass();
            try
            {
                Message.Print(string.Format(Resources.IntegerResult, myClassObject.MyInteger));
            }
            catch (Exception exception)
            {
                Message.Print(exception.Message);
            }
            finally
            {
                myClassObject.Dispose();
            }

            #endregion

            #region Linq

            Message.PrintTask(Resources.Linq);

            IEmployeeService   employService     = new EmployeeService();
            IDepartmentService departmentService = new DepartmentService();

            MessageHelper.PrintEmployees(employService.GetEmployees());
            MessageHelper.PrintDepartments(departmentService.GetDepartments());

            Message.PrintSubTask("Odd Salary Employee Details", 1);
            var employees = employService.GetOddSalaryEmployees();
            foreach (var employ in employees)
            {
                Message.Print(string.Format("'{0}' has salary Rs.{1}/-", employ.Name, employ.Salary));
            }

            Message.PrintSubTask("Get Employee Details by Department ", 2);
            var departmentEmployees = employService.GetEmployeesByDepartment(102);
            MessageHelper.PrintDepartmentEmployees(departmentEmployees);

            var highestSalaryByDepartment = employService.GetHighestSalaryByDepartment();
            Message.PrintSubTask("Highest Salary By Department", 3);

            foreach (var highSalaryEmployee in highestSalaryByDepartment)
            {
                Message.Print(string.Format("In Department '{0}', '{1}' has highest salary Rs.{2}/-", highSalaryEmployee.Department.Name, highSalaryEmployee.Name, highSalaryEmployee.Salary));
            }

            Message.PrintSubTask("Get Manager Details whose reportees are more than 2", 4);
            var managerList = employService.GetManagersByReporteeCount();
            MessageHelper.PrintManagerDetails(managerList);

            Message.PrintSubTask("Hike Salary with Business Rules", 5);
            int maleEmployeeId = 1, femaleEmployeeId = 2;
            var employeeRevisedSalary = employService.HikeSalary(maleEmployeeId);
            MessageHelper.PrintRevisedSalary(employeeRevisedSalary);
            employeeRevisedSalary = employService.HikeSalary(femaleEmployeeId);
            MessageHelper.PrintRevisedSalary(employeeRevisedSalary);

            Message.PrintSubTask("Get the salary details of employees under specific manager and increment the salary", 6);
            int managerId = 10;
            IEmployeeService cloneEmployeeService = employService.DeepCopy();
            var employList     = employService.GetEmployeesByManager(managerId);
            var employListCopy = cloneEmployeeService.GetEmployeesByManager(managerId);

            Message.Print("Before Deep Copy Salary Change");
            MessageHelper.PrintEmployeeDetails(employList);
            MessageHelper.PrintEmployeeDetails(employListCopy);

            foreach (var emp in employListCopy)
            {
                emp.Salary = cloneEmployeeService.HikeSalaryInPercent(emp.EmployeeId).Salary;
            }

            Message.Print("After Deep Copy Salary Change");
            MessageHelper.PrintEmployeeDetails(employList);
            MessageHelper.PrintEmployeeDetails(employListCopy);

            #endregion

            #region Collections and Generics

            Message.PrintTask(Resources.CollectionsAndGenerics);

            int registrationNumber = 1021;
            StudentCollection.SearchStudent(registrationNumber);

            // Sort the students by Total Score
            StudentCollection.SortStudentsByScore();
            #endregion

            #region Delegates And Events

            Message.PrintTask(Resources.DelegatesAndEvents);
            DelegatesAndEvents.ShoppingCart.PerformBilling();

            #endregion

            #region Exception Handling

            Message.PrintTask(Resources.ExceptionHandling);
            ExceptionDemo.ReadWeekDays();
            ExceptionDemo.ReadFileContent();

            #endregion

            Console.ReadLine();
        }
コード例 #40
0
 public EmployeeController(EmployeeService employeeService)
 {
     this.employeeService = employeeService;
 }
コード例 #41
0
 protected override async Task OnInitializedAsync()
 {
     Employees = (await EmployeeService.GetEmployees()).ToList();
 }
コード例 #42
0
 public EmployeeInfoCommand(EmployeeService employeeService)
 {
     this.employeeService = employeeService;
 }
コード例 #43
0
        public ActionResult All(string sessionid)
        {
            if (sessionid == null)
            {
                RedirectToAction("Login");
            }

            // for login employee sessin data
            Employee emp            = EmployeeService.GetUserBySessionId(sessionid);
            string   empRole        = emp.EmpRole;
            string   userName       = emp.UserName;
            string   empDisplayRole = emp.EmpDisplayRole;

            if (empRole == "STORE_CLERK" || empRole == "STORE_SUPERVISOR" || empRole == "STORE_MANAGER")
            {
                ViewData["userName"]  = userName;
                ViewData["sessionId"] = sessionid;
                return(View("~/Views/StoreLandingPage/Home.cshtml"));
            }
            else if ((empRole == "EMPLOYEE" || empRole == "REPRESENTATIVE") && (empDisplayRole != "HEAD"))
            {
                return(RedirectToAction("NewRequisition", "Requisition", new { sessionId = sessionid }));
            }
            //else if ((empRole=="HEAD" && empDisplayRole=="HEAD"))
            //{
            //    return RedirectToAction("GetPendingRequisitions","Requisition",new { sessionId=sessionid});
            //}
            else if ((empRole == "HEAD" && empDisplayRole == "HEAD"))
            {
                bool between = DelegateService.CheckDate(emp.DeptId);
                bool after   = DelegateService.AfterDate(emp.DeptId);
                if (between && !after)
                {
                    return(RedirectToAction("ViewDelegate", "Delegate", new { sessionId = sessionid }));
                }
                else if (!between && !after)
                {
                    return(RedirectToAction("GetPendingRequisitions", "Requisition", new { sessionId = sessionid }));
                }
                else if (!between && after)
                {
                    DelegateService.DelegateToPreviousHead(emp.DeptId);
                    return(RedirectToAction("GetPendingRequisitions", "Requisition", new { sessionId = sessionid }));
                }
                else
                {
                    return(RedirectToAction("GetPendingRequisitions", "Requisition", new { sessionId = sessionid }));
                }
            }
            else if ((empRole == "HEAD" && empDisplayRole == "EMPLOYEE"))
            {
                bool between = DelegateService.CheckDate(emp.DeptId);
                bool after   = DelegateService.AfterDate(emp.DeptId);
                if (between && !after)
                {
                    return(RedirectToAction("GetPendingRequisitions", "Requisition", new { sessionId = sessionid }));
                }
                else if (!between && !after)
                {
                    return(RedirectToAction("NewRequisition", "Requisition", new { sessionId = sessionid }));
                }
                else if (!between && after)
                {
                    DelegateService.DelegateToPreviousHead(emp.DeptId);
                    return(RedirectToAction("NewRequisition", "Requisition", new { sessionId = sessionid }));
                }
                else
                {
                    return(RedirectToAction("NewRequisition", "Requisition", new { sessionId = sessionid }));
                }
            }
            else
            {
                ViewData["userName"]  = userName;
                ViewData["sessionId"] = sessionid;
                return(null); //For departments' head landing page
            }
        }
コード例 #44
0
 public CreateAward(AwardService awardService, EmployeeService employeeService)
 {
     AwardService    = awardService;
     EmployeeService = employeeService;
 }
コード例 #45
0
 public void Initialize()
 {
     _employeeService = new EmployeeService();
     _service = new Service();
 }
コード例 #46
0
 public void loadEmployeeList()
 {
     EmployeeService employeeService = new EmployeeService();
     List<Employee> employees = employeeService.GetEmployees();
     setUpDataGrid(employees);
 }
コード例 #47
0
 public ActionResult Search(int branchId, int year, int month)
 {
     var employeeService = new EmployeeService();
     var employees = employeeService.GetMany(e => e.BranchId == branchId);
     var monthlySalaryDetails = employees.Select(x =>
         new MonthlySalaryDetail
         {
             EmpId = x.Id,
             Employee = x
         }
     );
     return PartialView("_List", monthlySalaryDetails);
 }
コード例 #48
0
        //
        // GET: /Employee/Delete
        public ActionResult Delete(long? id)
        {
            if (id == null)
            {
                return RedirectToAction("Index");
            }

            var viewModel = new EmployeeViewModel();

            using (ModelRepository db = new ModelRepository(this._factory.GetDatabaseObject()))
            {
                EmployeeService service = new EmployeeService(db);
                var model = service.GetObjectList(x => x.Id == id).FirstOrDefault();

                if (model == null)
                {
                    return RedirectToAction("Index");
                }

                viewModel = this._toViewModel(model);
            }

            return View(viewModel);
        }
コード例 #49
0
        /// <summary>
        /// This method is invoked up clicking the save button on the discard page
        /// This method sets up everything, it also process the items in the discard table
        /// then one-by-one each item is processed and updated in the database
        /// If there is any error, it will display an error message on the page
        /// </summary>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                pnlErrorMessage.Visible = true;
                litErrorMessage.Text    = "There are errors";
                return;
            }

            StringBuilder successMessage = new StringBuilder(10);

            DistributionCentre centre = (DistributionCentre)ViewState["DistributionCentre"];

            IEmployeeRepository repository = new EmployeeRepository(ConfigurationManager.ConnectionStrings["ENetCare"].ConnectionString);
            var employeeService            = new EmployeeService(repository);

            //Retrieve the viewstate for Employee Username
            string employeeUsername = (string)ViewState["EmployeeUsername"];

            Employee employee = employeeService.Retrieve(employeeUsername);

            DateTime expirationDate = DateTime.Now;

            //Go through each item in the list of packages that are to be distributed, and process them
            List <string> barcodes = ucPackageBarcode.GetBarcodes();

            for (int i = 0; i < barcodes.Count(); i++)
            {
                string packageTypeId = ucPackageBarcode.GetPackageTypeId(barcodes[i]);

                Package package = _packageService.Retrieve(barcodes[i]);

                StandardPackageType spt = _packageService.GetStandardPackageType(package.PackageType.PackageTypeId);

                //Update the database and change status to discard for selected packages
                var result = _packageService.Discard(barcodes[i], centre, employee, expirationDate, spt, package.PackageId);
                if (!result.Success)
                {
                    //if there was error updating the package then show error message
                    var err = new CustomValidator();
                    err.ValidationGroup = "destinationDetails";
                    err.IsValid         = false;
                    err.ErrorMessage    = string.Format("{0} - {1}", barcodes[i], result.ErrorMessage);
                    Page.Validators.Add(err);

                    pnlErrorMessage.Visible = true;
                    litErrorMessage.Text    = "There are errors";
                }
                else
                {
                    //Else if the item was successfully updated, append a success message to a placeholder
                    if (successMessage.Length == 0)
                    {
                        successMessage.Append("The following barcodes were discarded");
                    }

                    successMessage.AppendFormat(", {0}", barcodes[i]);
                }
            }

            //If the packages were successfully Distributed then show a success message
            if (successMessage.Length > 0)
            {
                pnlMessage.Visible = true;
                litMessage.Text    = successMessage.ToString();
            }

            //Disable Save button, and hide the barcode control
            ucPackageBarcode.Visible = false;
            btnSave.Enabled          = false;
            btnClose.Enabled         = true;
        }
コード例 #50
0
 public ProposalRequestViewModel(IView view)
     : base(view)
 {
     this.toList   = UserSession.CurrentProject.Contacts;
     this.fromList = EmployeeService.GetEmployees();
 }
コード例 #51
0
        private void LoadSearchViewBag(ProjectPlanCollectionSearch searchModel)
        {
            #region sort
            ViewBag.IsAsc = !searchModel.IsAsc;
            ViewBag.SortBy = searchModel.SortBy;
            #endregion
                var projectplanService = new ProjectPlanService();
                if (!searchModel.ProjectPlanId.HasValue)
                {
                    ViewBag.ProjectPlanId = new SelectList(projectplanService.Query(p => p.IsActive=="1"), "Id", "Name");
                }
                else
                {
                    ViewBag.ProjectPlanId = new SelectList(projectplanService.Query(p => p.IsActive=="1"), "Id", "Name", searchModel.ProjectPlanId);
                }
                var contractService = new ContractService();
                if (!searchModel.ContractId.HasValue)
                {
                    ViewBag.ContractId = new SelectList(contractService.Query(p => p.IsActive=="1"), "Id", "Name");
                }
                else
                {
                    ViewBag.ContractId = new SelectList(contractService.Query(p => p.IsActive=="1"), "Id", "Name", searchModel.ContractId);
                }
                var orgchartService = new OrgChartService();
                if (!searchModel.OrgChartId.HasValue)
                {
                    ViewBag.OrgChartId = new SelectList(orgchartService.Query(p => p.IsActive=="1"), "Id", "Name");
                }
                else
                {
                    ViewBag.OrgChartId = new SelectList(orgchartService.Query(p => p.IsActive=="1"), "Id", "Name", searchModel.OrgChartId);
                }
                var datadictionaryService = new DataDictionaryService();
                if (!searchModel.BidTypeId.HasValue)
                {
                    ViewBag.BidTypeId = new SelectList(datadictionaryService.Query(p => p.IsActive=="1"), "Id", "Name");
                }
                else
                {
                    ViewBag.BidTypeId = new SelectList(datadictionaryService.Query(p => p.IsActive=="1"), "Id", "Name", searchModel.BidTypeId);
                }
                var departmentService = new DepartmentService();
                if (!searchModel.DepartmentId.HasValue)
                {
                    ViewBag.DepartmentId = new SelectList(departmentService.Query(p => p.IsActive=="1"), "Id", "Name");
                }
                else
                {
                    ViewBag.DepartmentId = new SelectList(departmentService.Query(p => p.IsActive=="1"), "Id", "Name", searchModel.DepartmentId);
                }
                var employeeService = new EmployeeService();
                if (!searchModel.ResearchOwnerEmployeeId.HasValue)
                {
                    ViewBag.ResearchOwnerEmployeeId = new SelectList(employeeService.Query(p => p.IsActive=="1"), "Id", "Name");
                }
                else
                {
                    ViewBag.ResearchOwnerEmployeeId = new SelectList(employeeService.Query(p => p.IsActive=="1"), "Id", "Name", searchModel.ResearchOwnerEmployeeId);
                }

                if (!searchModel.EngeerEmployeeId.HasValue)
                {
                    ViewBag.EngeerEmployeeId = new SelectList(employeeService.Query(p => p.IsActive=="1"), "Id", "Name");
                }
                else
                {
                    ViewBag.EngeerEmployeeId = new SelectList(employeeService.Query(p => p.IsActive=="1"), "Id", "Name", searchModel.EngeerEmployeeId);
                }

                if (!searchModel.CostOwnerEmployeeId.HasValue)
                {
                    ViewBag.CostOwnerEmployeeId = new SelectList(employeeService.Query(p => p.IsActive=="1"), "Id", "Name");
                }
                else
                {
                    ViewBag.CostOwnerEmployeeId = new SelectList(employeeService.Query(p => p.IsActive=="1"), "Id", "Name", searchModel.CostOwnerEmployeeId);
                }

                if (!searchModel.AuthorEmployeeId.HasValue)
                {
                    ViewBag.AuthorEmployeeId = new SelectList(employeeService.Query(p => p.IsActive=="1"), "Id", "Name");
                }
                else
                {
                    ViewBag.AuthorEmployeeId = new SelectList(employeeService.Query(p => p.IsActive=="1"), "Id", "Name", searchModel.AuthorEmployeeId);
                }

                if (!searchModel.OrganizerEmployeeId.HasValue)
                {
                    ViewBag.OrganizerEmployeeId = new SelectList(employeeService.Query(p => p.IsActive=="1"), "Id", "Name");
                }
                else
                {
                    ViewBag.OrganizerEmployeeId = new SelectList(employeeService.Query(p => p.IsActive=="1"), "Id", "Name", searchModel.OrganizerEmployeeId);
                }
        }
コード例 #52
0
 public SimpleListVM(EmployeeService employeeService)
 {
     _employeeService = employeeService;
 }
コード例 #53
0
 public SetManagerCommand(EmployeeService employeeService)
 {
     this.employeeService = employeeService;
 }
コード例 #54
0
 public LoginScreen()
 {
     InitializeComponent();
     employeeService = new EmployeeService();
 }
コード例 #55
0
 public ManagerInfoCommand(EmployeeService employeeService)
 {
     this.employeeService = employeeService;
 }
コード例 #56
0
 public EmployeesController()
 {
     Service = new EmployeeService();
 }
コード例 #57
0
        private void dgvEmployeeList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (sender is DataGridView)
            {
                DataGridViewCell cell = ((DataGridView)sender).CurrentCell;
                if (cell.ColumnIndex == ((DataGridView)sender).ColumnCount - 1)
                {
                    DialogResult result = MessageBox.Show("Bạn có muốn xóa nhân viên này?",
                    "Xoá nhân viên này",
                     MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        DataGridViewRow currentRow = dgvEmployeeList.Rows[e.RowIndex];

                        EmployeeService employeeService = new EmployeeService();
                        int id = ObjectHelper.GetValueFromAnonymousType<int>(currentRow.DataBoundItem, "Id");

                        if (!employeeService.DeleteEmployee(id))
                        {
                            MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);

                        }
                        loadEmployeeList();
                    }

                }

            }
        }
コード例 #58
0
 public bool ValidDeleteObject(TitleInfo titleInfo, EmployeeService _employeeService)
 {
     //titleInfo.Errors.Clear();
     VDontHaveEmployees(titleInfo, _employeeService);
     return(isValid(titleInfo));
 }
コード例 #59
0
        public StoreWeekCalculater(long storeid, DateTime abegin, DateTime aend, EmployeeTimeService timeservice)
        {
            _storeid = storeid;
            _begindate = abegin;
            _enddate = aend;

            _timeservice = timeservice;
            _employeeservice = _timeservice.EmployeeService as EmployeeService;
            _storeservice = _employeeservice.StoreService as StoreService;

            CountryId = _storeservice.GetCountryByStoreId(_storeid);

            _absencemanager = new AbsenceManager(_storeservice.CountryService.AbsenceService);
            _absencemanager.CountryId = CountryId;

            _wmodelmanager = new WorkingModelManagerNew(_storeservice.CountryService.WorkingModelService);
            _wmodelmanager.CountryId = CountryId;

            Init();
        }
コード例 #60
0
        protected override void Load(ContainerBuilder builder)
        {
            var employeeService = new EmployeeService();

            builder.RegisterInstance(employeeService).AsImplementedInterfaces();
        }