public bool Update(TrieuChungDTO trieuchungDto) { try { var trieuchung = _trieuchungRepository.GetById(trieuchungDto.MaTrieuChung); // check nhan vien exist if (trieuchung == null) { return(false); } //Update nhan vien detail trieuchung.MaTrieuChung = trieuchungDto.MaTrieuChung; trieuchung.TenTrieuChung = trieuchungDto.TenTrieuChung; trieuchung.MoTaTrieuChung = trieuchungDto.MoTaTrieuChung; // trieuchung.MaBenh = trieuchungDto.MaBenh; // update user _trieuchungRepository.Update(trieuchung); _unitOfWork.Commit(); return(true); } catch (Exception ex) { return(false); } }
public async Task <BaseResponse> Update(TrieuChungDTO trieuchungDTO) { try { var result = _TrieuChungService.Update(trieuchungDTO); if (result) { return(await Task.FromResult(new BaseResponse(result))); } return(await Task.FromResult(new BaseResponse(Message.UpdateNotSuccess, false)).ConfigureAwait(false)); } catch (Exception e) { return(await Task.FromResult(new BaseResponse(Message.UpdateNotSuccess, false)).ConfigureAwait(false)); } }
public async Task <BaseResponse> Create(TrieuChungDTO trieuchungDto) { try { var result = _TrieuChungService.Create(trieuchungDto); if (result) { return(await Task.FromResult(new BaseResponse(result))); } return(await Task.FromResult(new BaseResponse(Message.CreateNotSuccess))); } catch (Exception e) { return(await Task.FromResult(new BaseResponse(Message.CreateNotSuccess))); } }
public bool Create(TrieuChungDTO trieuchungDto) { try { var item = CheckExistsTenTrieuChung(trieuchungDto.TenTrieuChung); if (item) { return(false); } var trieuchung = new TrieuChung { MaTrieuChung = Guid.NewGuid(), TenTrieuChung = trieuchungDto.TenTrieuChung, MoTaTrieuChung = trieuchungDto.MoTaTrieuChung, // MaBenh = trieuchungDto.MaBenh }; _trieuchungRepository.Insert(trieuchung); _unitOfWork.Commit(); if (trieuchungDto.MaBenhs != null) { foreach (var mabenh in trieuchungDto.MaBenhs) { var trieuchungbenh = new TrieuChungBenh { MaTrieuChung = trieuchung.MaTrieuChung, MaBenh = new Guid(mabenh) }; _trieuchungbenhRepository.Insert(trieuchungbenh); } _unitOfWork.Commit(); } return(true); }catch (Exception ex) { return(false); } }