EmployeeCommendation GetFields(EmployeeCommendation work) { work.CommendedBy = User; work.RecievingEmployee = (Employee)cbEmployee.SelectedEmployee; work.Notes = txtNotes.Text; work.EmployeeCommendationClassification = (EmployeeCommendationClassification)cbClassification.SelectedValue; return work; }
private void AddEditStaffCommendation_Load(object sender, EventArgs e) { var unitOfWork = new UnitOfWork(); cbClassification.DisplayMember = "Name"; cbEmployee.Rebind(); cbClassification.DataSource = unitOfWork.EmployeeCommendationClassificationRepository.Get(x=> x.AvailableOnUser).ToList(); if (currentCommendationId!= null) { currentCommendation = unitOfWork.EmployeeCommendationRepository.Get(x => x.Id == currentCommendationId).FirstOrDefault(); txtNotes.Text = currentCommendation.Notes; cbEmployee.SelectedEmployee = currentCommendation.RecievingEmployee; } }
private void button1_Click(object sender, EventArgs e) { var unitOfWork = new UnitOfWork(); //TODO: Validate Inputs if (currentCommendationId != null) { unitOfWork.EmployeeCommendationRepository.Update(GetFields(currentCommendation)); } else { currentCommendation = GetFields(new EmployeeCommendation()); currentCommendation.DateCreated = DateTime.Now; unitOfWork.EmployeeCommendationRepository.Insert(currentCommendation); } unitOfWork.Save(); this.DialogResult = DialogResult.OK; }