示例#1
0
        public Guid Upsert(EmployeeProxy proxy)
        {
            try
            {
                var      repo = this.RepoFactory.Get <EmployeeRepository>();
                Employee employee;

                if (proxy.Id.HasValue)
                {
                    employee = repo.GetById(proxy.Id);
                }
                else
                {
                    employee    = new Employee();
                    employee.Id = Guid.NewGuid();
                    repo.Add(employee);
                }

                employee.Name = proxy.Name;

                repo.SaveChanges();

                return(employee.Id);
            }
            catch (Exception)
            {
                throw new UserException("Грешка при записването на служителя");
            }
        }
示例#2
0
        public void CreateEmployeeClicked()
        {
            Mediator.GetInstance().CreateEmployeeClicked += () =>
            {
                try
                {
                    Employee      emp      = new Employee();
                    EmployeeProxy empProxy = new EmployeeProxy();

                    emp.Name       = TxtName.Text;
                    emp.Email      = TxtEmail.Text;
                    emp.Phone      = TxtPhone.Text;
                    emp.NoOfHours  = Convert.ToInt32(TxtNoOfHours.Text);
                    emp.IsAdmin    = Convert.ToBoolean(ChkIsAdmin.IsChecked);
                    emp.IsEmployed = Convert.ToBoolean(ChkIsActive.IsChecked);
                    emp.Username   = TxtUsername.Text;
                    emp.Password   = TxtPassword.Text;
                    Department selectedDepartment = (Department)CBoxDepartment.SelectedItem;
                    emp.DepartmentId = selectedDepartment.Id;

                    empProxy.InsertEmployee(emp);

                    MessageBox.Show("An employee was succesfully saved", "Saved Employee");
                }
                catch (ArgumentException)
                {
                    MessageBox.Show("Something went wrong while processing your request. Please check input parameters.");
                }
                ClearEmployeeView();
            };
        }
示例#3
0
        public void UpdateEmployeeClicked()
        {
            Mediator.GetInstance().UpdateEmployeeClicked += () =>
            {
                try
                {
                    EmployeeProxy empProxy = new EmployeeProxy();
                    Employee      emp      = (Employee)EmployeeListBox.SelectedItem;
                    emp.Name       = TxtName.Text;
                    emp.Email      = TxtEmail.Text;
                    emp.Phone      = TxtPhone.Text;
                    emp.NoOfHours  = Convert.ToInt32(TxtNoOfHours.Text);
                    emp.IsAdmin    = Convert.ToBoolean(ChkIsAdmin.IsChecked);
                    emp.IsEmployed = Convert.ToBoolean(ChkIsActive.IsChecked);
                    emp.Username   = TxtUsername.Text;
                    emp.Password   = TxtPassword.Password;

                    empProxy.UpdateEmployee(emp);

                    MessageBox.Show("An employee was succenfully updated", "Updated Employee");
                }
                catch (Exception)
                {
                    MessageBox.Show("Something went wrong while processing your request. Please check input parameters.", "Error:");
                }
                ClearEmployeeView();
                LoadDepartmentList();
            };
        }
示例#4
0
 public UpdateEmployeeView()
 {
     departmentProxy = new DepartmentProxy();
     InitializeComponent();
     LoadDepartmentList();
     UpdateEmployeeClicked();
     empProxy = new EmployeeProxy();
 }
示例#5
0
 /// <summary>
 ///     Constructor initializes commands
 /// </summary>
 public EmployeeHomeViewModel()
 {
     OnPageLoadCommand     = new RelayCommand(OnPageLoad);
     RemoveEmployeeCommand = new RelayCommand(RemoveEmployee);
     EditEmployeeCommand   = new RelayCommand(EditEmployee);
     _cts           = new CancellationTokenSource();
     _employeeProxy = new EmployeeProxy();
 }
 /// <summary>
 ///     Constructor initializes Commands
 /// </summary>
 public EmployeeFormViewModel()
 {
     TitleText           = "Stwórz Pracownika";
     SaveEmployeeCommand = new RelayCommand(SaveEmployee, SaveCanExcecute);
     OnPageLoadCommand   = new RelayCommand(OnPageLoad);
     _cts            = new CancellationTokenSource();
     _employeeProxy  = new EmployeeProxy();
     _sportTypeProxy = new SportTypeProxy();
     _positionProxy  = new PositionProxy();
 }
示例#7
0
 public EnrolmentSingleServiceViewModel()
 {
     _customerProxy    = new CustomerProxy();
     _serviceProxy     = new ServicesProxy();
     _serviceTypeProxy = new ServiceTypeProxy();
     _employeeProxy    = new EmployeeProxy();
     OnPageLoadCommand = new RelayCommand(OnPageLoad);
     EnrolCommand      = new RelayCommand(Enrol, EnrolCanExcecute);
     Initialize();
 }
示例#8
0
 public void GetListOfEmployeesBasedOnDepartment(int departmentId)
 {
     try
     {
         EmployeeProxy   empProxy     = new EmployeeProxy();
         List <Employee> employeeList = empProxy.GetEmployeesByDepartmentId(departmentId);
     }
     catch (Exception)
     {
         MessageBox.Show("Something went wrong! Could not feth employees");
     }
 }
示例#9
0
 public AddCourseViewModel()
 {
     _employeeProxy        = new EmployeeProxy();
     _serviceTypeProxy     = new ServiceTypeProxy();
     _servicesProxy        = new ServicesProxy();
     Course                = new Course();
     SaveChangesCommand    = new RelayCommand(SaveChanges);
     AddCourseCommand      = new RelayCommand(AddCourse, AddCourseCanExcecute);
     OnPageLoadCommand     = new RelayCommand(OnPageLoad);
     AddDateCommand        = new RelayCommand(AddDate, AddDateCanExcecute);
     RemoveCustomerCommand = new RelayCommand(RemoveCustomer);
     RemoveDateCommand     = new RelayCommand(RemoveDate);
     RemoveCourseCommand   = new RelayCommand(RemoveCourse);
 }
        public JsonResult Upsert(EmployeeProxy proxy)
        {
            var response = new ResponseModel();

            try
            {
                response.Data = Service.Upsert(proxy);
            }
            catch (Exception ex)
            {
                response.SetException(ex);
            }

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
示例#11
0
        public ActionResult Authorize(EmployeeModel loggingIn)
        {
            EmployeeProxy empProxy = new EmployeeProxy();

            try
            {
                Employee employee = empProxy.ValidatePassword(loggingIn.Username, loggingIn.Password);
                Session["employee"] = employee;
                return(RedirectToAction("Index", "Home"));
            }
            catch (Exception)
            {
                ModelState.AddModelError("", "Wrong username or password");
                return(RedirectToAction("Index", "Login"));
            }
        }
 public void SetOnTemplateScheduleSelected()
 {
     Mediator.GetInstance().TemplateScheduleSelected += (s, e) =>
     {
         try
         {
             EmployeeProxy   employeeProxy = new EmployeeProxy();
             List <Employee> employees     = employeeProxy.GetEmployeesByDepartmentId(e.TemplateSchedule.DepartmentId);
             LoadEmployeeList(employees);
         }
         catch (Exception)
         {
             MessageBox.Show("Something went wrong! Could not feth employees");
         }
     };
 }
示例#13
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Employee      employee      = null;
            EmployeeProxy employeeProxy = new EmployeeProxy();

            try
            {
                employee = employeeProxy.ValidatePassword(TxtUsername.Text, PwBox.Password);
                if (employee != null && employee.IsAdmin)
                {
                    Mediator.GetInstance().OnLoginButtonClicked(employee);
                }
                else
                {
                    ShowErrorMessage();
                }
            }
            catch (Exception)
            {
                ShowErrorMessage();
            }
        }
示例#14
0
    public override void Execute(INotification notification)
    {
        EmployeeProxy employeeProxy = Facade.RetrieveProxy(EmployeeProxy.NAME) as EmployeeProxy;

        employeeProxy.EmployEmployee((int)notification.Body);
    }