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("Грешка при записването на служителя"); } }
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(); }; }
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(); }; }
public UpdateEmployeeView() { departmentProxy = new DepartmentProxy(); InitializeComponent(); LoadDepartmentList(); UpdateEmployeeClicked(); empProxy = new EmployeeProxy(); }
/// <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(); }
public EnrolmentSingleServiceViewModel() { _customerProxy = new CustomerProxy(); _serviceProxy = new ServicesProxy(); _serviceTypeProxy = new ServiceTypeProxy(); _employeeProxy = new EmployeeProxy(); OnPageLoadCommand = new RelayCommand(OnPageLoad); EnrolCommand = new RelayCommand(Enrol, EnrolCanExcecute); Initialize(); }
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"); } }
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)); }
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"); } }; }
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(); } }
public override void Execute(INotification notification) { EmployeeProxy employeeProxy = Facade.RetrieveProxy(EmployeeProxy.NAME) as EmployeeProxy; employeeProxy.EmployEmployee((int)notification.Body); }