public bool ChangePassword(Guid staffId, string password) { bool changepass = false; try { IUnitOfWork ouw = new UnitOfWork(); IStaffRepository rep = new StaffRepository(ouw); IStaffService service = new StaffService(rep); var result = rep.GetStaffById(staffId); if (result != null) { result.Password = Utility.MD5(password); rep.UpdateStaff(result); } } catch (Exception ex) { changepass = false; IErrorLogService errorLog = new ErrorLogService(); string message = ex.InnerException != null ? ex.InnerException.InnerException.Message : ex.Message; throw new Exception(ex.Message); } return(changepass); }
public void UpdateStaff_WithExistsStaff_UpdateStaffList() { var staffUpdated = new staff() { id = 1, full_name = "nvupdate", date_of_birth = new DateTime(1999, 1, 3), phone_number = "0945664870", salary = 700000, is_still_working = true, permission_id = 1 }; _sut.UpdateStaff(staffUpdated); var staffUpdatedVM = new StaffViewModel() { Id = 1, FullName = "nvupdate", DateOfBirth = new DateTime(1999, 1, 3), PhoneNumber = "0945664870", Salary = 700000, PositionName = "QUAN LY" }; _sut.GetStaffList().Should().ContainEquivalentOf(staffUpdatedVM); }
public ActionResult AddStaff(StaffModel staffModel) { try { if (staffModel.FileName.ContentLength > 0) { if (ModelState.IsValid) { string _PhotoName = Path.GetFileName(staffModel.FileName.FileName).Replace(" ", ""); string _path = Path.Combine(Server.MapPath("~/UploadedFiles"), _PhotoName); staffModel.FileName.SaveAs(_path); StaffTable staffTable = new StaffTable() { ID = staffModel.ID, ACDetails = staffModel.ACDetails, DateOfBirth = staffModel.DateOfBirth, DateOfJoin = staffModel.DateOfJoin, Designation = staffModel.Designation, Salary = staffModel.Salary, Experience = staffModel.Experience, SchoolMatric = staffModel.SchoolMatric, Name = staffModel.Name, Staff = staffModel.Staff, Qualification = staffModel.Qualification, PhotoGraph = "/UploadedFiles/" + _PhotoName }; if (staffTable.ID > 0) { staffRepository.UpdateStaff(staffTable); } else { staffRepository.InsertStaff(staffTable); } } } else { return(View(staffModel)); } return(RedirectToAction("Technical")); } catch (Exception) { return(View(staffModel)); } }
public ActionResult StaffCreate(StaffModel staffModel) { try { Staff staff = new Staff { ID = staffModel.ID, AadharNumber = staffModel.AadharNumber, DateOfBirth = staffModel.DateOfBirth, DateOfJoin = staffModel.DateOfJoin, Salary = staffModel.Salary, StaffName = staffModel.StaffName, StaffType = staffModel.StaffType, Subject = staffModel.Subject, SubjectNumFirst = staffModel.SubjectNumFirst, SubjectNumSecond = staffModel.SubjectNumSecond, TeachSubFirst = staffModel.TeachSubFirst, TeachSubSecond = staffModel.TeachSubSecond, Designation = staffModel.Designation, Experience = staffModel.Experience, FatherName = staffModel.FatherName, PanNumber = staffModel.PanNumber }; if (ModelState.IsValid) { if (staff.ID > 0) { staffRepository.InsertStaff(staff); } else { staffRepository.UpdateStaff(staff); } } else { return(View(staffModel)); } return(RedirectToAction("TeachingSatff")); } catch (Exception) { return(View(staffModel)); } }
public ActionResult Index() { StaffRepository staff = new StaffRepository(); SuppliersRepository Supplier = new SuppliersRepository(); staff.CreateStaff(); staff.InsertStaff_StoredProcedure(); staff.UpdateStaff(); staff.GetStaff(); //staff.DeleteWardStaffAllocation(); //staff.DeleteStaff(); staff.GetStaffView(); Supplier.CreateSupplier(); Supplier.UpdateSupplier(); Supplier.GetSupplier(); //Supplier.DeleteSupplier(); return(View()); }
private void btnAddStaff_Click(object sender, EventArgs e) { if (txtFirstName.isEmptyOrHint()) { txtFirstName.Focus(); return; } if (txtLastName.isEmptyOrHint()) { txtLastName.Focus(); return; } if (txtAddress1.isEmptyOrHint()) { txtAddress1.Focus(); return; } if (txtAddress2.isEmptyOrHint()) { txtAddress2.Focus(); return; } if (txtCity.isEmptyOrHint()) { txtCity.Focus(); return; } if (txtCountry.isEmptyOrHint()) { txtCountry.Focus(); return; } if (txtPostalCode.isEmptyOrHint()) { txtPostalCode.Focus(); return; } if (txtPhoneNumber.isEmptyOrHint()) { txtPhoneNumber.Focus(); return; } if (txtQualification.isEmptyOrHint()) { txtQualification.Focus(); return; } Staff newStaff = new Staff() { FirstName = txtFirstName.Text.Trim(), LastName = txtLastName.Text.Trim(), Address1 = txtAddress1.Text.Trim(), Address2 = txtAddress2.Text.Trim(), City = txtCity.Text.Trim(), Country = txtCountry.Text.Trim(), PostalCode = txtPostalCode.Text.Trim(), PhoneNumber = txtPhoneNumber.Text.Trim(), Qualification = txtQualification.Text.Trim(), Password = txtPassword.Text.Trim(), Username = txtUsername.Text.Trim(), }; if (_isUpdate) { if (_updatedStaff == null) { MessageBox.Show("Error in system!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } newStaff.Id = _updatedStaff.Id; int res = _sr.UpdateStaff(newStaff); if (res < 0) { MessageBox.Show("Error In Update!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { ActionPerformed?.Invoke(newStaff, ActionType.Updated); Hide(); } } else { int res = _sr.AddStaffMember(newStaff); if (res < 0) { MessageBox.Show("Error In Adding New Staff!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { newStaff.Id = res; ActionPerformed?.Invoke(newStaff, ActionType.Added); Hide(); } } Clear(); }
public StaffModel RegisterTranslator(StaffModel model) { try { IUnitOfWork ouw = new UnitOfWork(); IStaffRepository rep = new StaffRepository(ouw); IStaffService service = new StaffService(rep); IStaffBankAccountInfoRepository bankrep = new StaffBankAccountInfoRepository(ouw); IStaffBankAccountInfoService bankservice = new StaffBankAccountInfoService(bankrep); IStaffSoftwareRepository _staffsoftwareRepository = new StaffSoftwareSkillRepository(ouw); IStaffProfessioanlSpecialityRepository _spRepository = new StaffProfessioanlSpecialityRepository(ouw); IStaffCurrentStateRepository _cstateRepository = new StaffCurrentStateRepository(ouw); if (model.ID == Guid.Empty) { model.ID = Guid.NewGuid(); model.Password = Utility.MD5(model.Password); model.CreatedDate = DateTime.Now; model.RegistrationDate = DateTime.Now; Utility.SetDynamicPropertyValue(model, model.CurrentCulture); var map = Mapper.Map <StaffModel, Staff>(model); rep.InsertStaff(map); //model.Staffbank.ID = model.ID; if (model.Staffbank.ID == Guid.Empty) { model.Staffbank.ID = Guid.NewGuid(); model.Staffbank.StaffID = model.ID; // model.Staffbank.CurrentCulture = model.CurrentCulture; Utility.SetDynamicPropertyValue(model.Staffbank, model.CurrentCulture); var bnk = Mapper.Map <StaffBankAccountInfoModel, Staff_BankAccountInfo>(model.Staffbank); bankrep.InsertStaffBankAccountInfo(bnk); } } else { Utility.SetDynamicPropertyValue(model, model.CurrentCulture); var map = Mapper.Map <StaffModel, Staff>(model); var bnk = Mapper.Map <StaffBankAccountInfoModel, Staff_BankAccountInfo>(model.Staffbank); rep.UpdateStaff(map); bankrep.UpdateStaffBankAccountInfo(bnk); } foreach (StaffSoftwareSkillModel staff in model.staffsoft) { staff.StaffID = model.ID; var software = Mapper.Map <StaffSoftwareSkillModel, Staff_SoftwareSkill>(staff); if (staff.ID == Guid.Empty) { software.CreatedDate = DateTime.Now; software.ID = Guid.NewGuid(); _staffsoftwareRepository.InsertStaffSkill(software); } else { software.UpdatedDate = DateTime.Now; software.UpdatedBy = staff.UpdatedBy; _staffsoftwareRepository.UpdateStaffSkill(software); } } foreach (StaffProfesionalSpecialityModel professional in model.StaffProfessional) { professional.StaffID = model.ID; var staffspecial = Mapper.Map <StaffProfesionalSpecialityModel, Staff_ProfessionalSpeciality>(professional); if (professional.ID > 0) { _spRepository.UpdateStaffProfessinalSpeciality(staffspecial); } else { _spRepository.InsertStaffProfessinalSpeciality(staffspecial); } } foreach (StaffCurrentStateModel state in model.StaffCurrentState) { state.StaffID = model.ID; var staffcurrentstate = Mapper.Map <StaffCurrentStateModel, Staff_CurrentStates>(state); if (state.ID > 0) { _cstateRepository.UpdateStaffCurrentState(staffcurrentstate); } else { _cstateRepository.InsertStaffCurrentState(staffcurrentstate); } } } catch (Exception ex) { model = null; //isRegistered = false; //IErrorLogService errorLog = new ErrorLogService(); string message = ex.InnerException != null ? ex.InnerException.InnerException.Message : ex.Message; //errorLog.SetErrorLog(model.CurrentUserID, "TranslatorRegistrationFromTranspro", message); throw new Exception(ex.Message); } return(model); }
// PUT: api/Staff/5 /// <summary> /// Replace existing staff with the staff from body by its id /// </summary> /// <param name="id"></param> /// <param name="updatedStaff"></param> /// <returns>bool</returns> public bool Put(int id, [FromBody] StaffModel updatedStaff) { return(_staffRepository.UpdateStaff(id, updatedStaff)); }