public bool InsertWorkerMaster(WorkerMasterResponse workerMaster) { if (workerMaster == null || workerMaster.HeadImage == null) { throw new ArgumentNullException("workerMaster/HeadImage is null"); } byte[] image = Encoding.UTF8.GetBytes(workerMaster.HeadImage.ToString()); var obj = new WorkerMaster() { Id = workerMaster.Id, Address = workerMaster.Address, WorkerName = workerMaster.WorkerName, IDCardType = workerMaster.IDCardType, IDCardNumber = workerMaster.IDCardNumber, Gender = workerMaster.Gender, Nation = workerMaster.Nation, Birthday = workerMaster.Birthday, BirthPlaceCode = workerMaster.BirthPlaceCode, HeadImage = image, PoliticsType = workerMaster.PoliticsType, IsJoined = workerMaster.IsJoined, JoinedTime = workerMaster.JoinedTime, CellPhone = workerMaster.CellPhone, CultureLevelType = workerMaster.CultureLevelType, HasBadMedicalHistory = workerMaster.HasBadMedicalHistory, UrgentContractName = workerMaster.UrgentContractName, UrgentContractCellphone = workerMaster.UrgentContractCellphone, WorkTypeCode = workerMaster.WorkTypeCode, WorkDate = workerMaster.WorkDate, }; bool result = _workerMasterRepository.Insert(obj); return(result); }
public HttpResponseMessage UpdateWorkerMaster(WorkerMaster workerMaster) { var result = _workerMasterService.UpdateWorkerMaster(workerMaster); return(result ? toJson(null, OperatingState.Success, "修改成功") : toJson(null, OperatingState.Failure, "修改失败")); }
/// <summary> /// コンストラクタ /// </summary> public MainWindowViewModel() { DataBaseManager.ConnectDB("WorkTaskApp.db"); WorkContents = new ObservableCollection <WorkContent>(DataBaseManager.DBManager.GetWorkContents()); PesticideMasters = new ObservableCollection <PesticideMaster>(DataBaseManager.DBManager.GetPesticideMasters()); WorkerMasters = new ObservableCollection <WorkerMaster>(DataBaseManager.DBManager.GetWorkerMasters()); WorkContent = new WorkContent(); PesticideContent = new PesticideContent(); WorkerMaster = new WorkerMaster(); RegisterPesticide = new PesticideMaster(); RegisterWorker = new WorkerMaster(); // 農薬内容登録コマンド登録 RegisterPesticideContentClicked = new DelegateCommand( () => RegisterPesticideContent()); // 農薬内容更新コマンド登録 UpdatePesticideContentClicked = new DelegateCommand( () => UpdatePesticideContent()); // 農薬内容削除コマンド登録 DeletePesticideContentClicked = new DelegateCommand( () => DeletePesticideContent()); // 農薬内容読み込みコマンド登録(クリックで取得したインスタンスで登録用インスタンスを上書き) PesticideContentsClicked = new DelegateCommand <Object>( (readPesticideContent) => { if (readPesticideContent is PesticideContent) { // インデックスを取得 selectedPesticideContentIndex = PesticideContentIndex; // リスト内の要素が選択されている場合のみ、インスタンスを上書きする PesticideContent = new PesticideContent((PesticideContent)readPesticideContent); PesticideMasterIndex = PesticideMasters.ToList().FindIndex(master => PesticideContent.PestcideMaster.Id == master.Id); } }); // 作業内容登録コマンド登録 RegisterWorkContentClicked = new DelegateCommand( () => RegisterWorkContent()); // 作業内容更新コマンド登録 UpdateWorkContentClicked = new DelegateCommand( () => UpdateWorkContent()); // 作業内容削除コマンド登録 DeleteWorkContentClicked = new DelegateCommand( () => DeleteWorkContent()); // 作業内容読み込みコマンド登録(クリックで取得したインスタンスで登録用インスタンスを上書き) WorkContentsClicked = new DelegateCommand <Object>( (readWorkContent) => { if (readWorkContent is WorkContent) { // リスト内の要素が選択されている場合のみ、インスタンスを上書きする WorkContent = new WorkContent((WorkContent)readWorkContent); WorkerMasterIndex = WorkerMasters.ToList().FindIndex(master => WorkContent.UserId == master.Id); } }); // 農薬マスタ登録コマンド登録 RegisterPesticideClicked = new DelegateCommand( () => RegisterPesticideMaster()); // 農薬マスタ更新コマンド登録 UpdatePesticideClicked = new DelegateCommand( () => UpdatePesticideMaster()); // 農薬マスタ削除コマンド登録 DeletePesticideClicked = new DelegateCommand( () => DeletePesticideMaster()); // 農薬マスタ読み込みコマンド登録(クリックで取得したインスタンスで登録用インスタンスを上書き) PesticideMasterClicked = new DelegateCommand <Object>( (readPesticide) => { if (readPesticide is PesticideMaster) { // リスト内の要素が選択されている場合のみ、インスタンスを上書きする RegisterPesticide = new PesticideMaster((PesticideMaster)readPesticide); } }); // 作業者マスタ登録コマンド登録 RegisterWorkerClicked = new DelegateCommand( () => RegisterWorkerMaster()); // 作業者マスタ更新コマンド登録 UpdateWorkerClicked = new DelegateCommand( () => UpdateWorkerMaster()); // 作業者マスタ削除コマンド登録 DeleteWorkerClicked = new DelegateCommand( () => DeleteWorkerMaster()); // 作業者マスタ読み込みコマンド登録(クリックで取得したインスタンスで登録用インスタンスを上書き) WorkerMasterClicked = new DelegateCommand <Object>( (readWorker) => { if (readWorker is WorkerMaster) { // リスト内の要素が選択されている場合のみ、インスタンスを上書きする RegisterWorker = new WorkerMaster((WorkerMaster)readWorker); } }); }