public IEnumerable <OperacaoDTO> GetOperacoesByDescricaoTipoMaquina(String descricao) { long id = 0; List <TipoMaquina> listaTipo = _context.TipoMaquinas.ToList(); foreach (TipoMaquina tm in listaTipo) { if (tm.descricao.descricao == descricao) { id = tm.Id; } } IEnumerable <Operacao> operacaoL = TMORepo.SelectOperacoesByIdTM(id); List <OperacaoDTO> listaFinal = new List <OperacaoDTO> (); foreach (Operacao p in operacaoL) { long tipoOp = p.tipoOpId; TipoOperacao to = TORepo.SelectById(tipoOp); listaFinal.Add(ToDTO.OperacaoToOperacaoDTO(p, to)); } IEnumerable <OperacaoDTO> l = listaFinal; return(l); }
private void btnThem_Click(object sender, EventArgs e) { ToDTO T = new ToDTO(); T.NgayLap = dtkNgayLap.Value; if (ToBUS.ThemTo(T) == true) { MessageBox.Show("Thêm tổ thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadData(); Reset(); } else { MessageBox.Show("Thêm tổ thất bại.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void GetAPointOfInterestForCity_CityAndPoiExist_ReturnsThePoiForTheCity() { //Arrange var anyCity = CityFaker.Generate(); var anyPoi = anyCity.PointsOfInterests.FirstOrDefault(); var aPoiForACityDTO = ToDTO.ToAPoiForACityDto(anyPoi); MockCityRepository.CityExists(anyCity.Id).Returns(true); MockCityRepository.GetPointOfInterestForCity(anyCity.Id, anyPoi.Id).Returns(anyPoi); //Action var result = CityController.GetAPointOfInterestForCity(anyCity.Id, anyPoi.Id); // Assert result.Should().BeOfType <ObjectResult>() .Which.Value.ShouldBeEquivalentTo(aPoiForACityDTO); }
public void GetAll_CitiesExist_ReturnCitiesDTO() { //Arrange int nbOfCities = 4; var cities = CityFaker.Generate(nbOfCities); string name = ""; var citiesDTO = ToDTO.ToCitiesDto(cities); MockCityRepository.GetCities().Returns(cities); //Action var result = CityController.GetCities(name); // Assert result.Should().BeOfType <ObjectResult>() .Which.Value.ShouldBeEquivalentTo(citiesDTO); }
public static bool ThemTo(ToDTO T) { try { SqlConnection con = DataProvider.Connection(); SqlCommand cmd = new SqlCommand("sp_ThemTo", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@NgayLap", SqlDbType.Date); cmd.Parameters["@NgayLap"].Value = T.NgayLap; cmd.ExecuteNonQuery(); con.Close(); return(true); } catch { return(false); } }
private void btnCapNhat_Click(object sender, EventArgs e) { ToDTO T = new ToDTO(); T.MaTo = Int32.Parse(txtMaTo.Text); T.NgayLap = dtkNgayLap.Value; try { T.ToTruong = cboToTruong.SelectedValue.ToString(); } catch { T.ToTruong = "NULL"; } if (ToBUS.CapNhatTo(T) == true) { MessageBox.Show("Cập nhật tổ thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadData(); Reset(); } else { MessageBox.Show("Cập nhật tổ thất bại.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void GetAllPointsOfInterestForCity_CityExist_ReturnsAllPoiForACityDTO() { //Arrange var anyCity = CityFaker.Generate(); var allPoiForACityDTO = ToDTO.ToPoiDto(anyCity.PointsOfInterests); MockCityRepository.CityExists(anyCity.Id).Returns(true); MockCityRepository.GetPointsOfInterestForCity(anyCity.Id).Returns(anyCity.PointsOfInterests); //Action var result = CityController.GetAllPointsOfInterestForCity(anyCity.Id); // Assert result.Should().BeOfType <ObjectResult>() .Which.Value.ShouldBeEquivalentTo(allPoiForACityDTO); }
public void GetAll_ForASpecificCity_ReturnTheCityDTO() { //Arrange int nbOfCities = 4; var cities = CityFaker.Generate(nbOfCities); cities[0].Name = "Paris"; string name = cities[0].Name; var citiesDTO = ToDTO.ToCitiesDto(cities); MockCityRepository.GetCities().Returns(cities); //Action var result = CityController.GetCities(name); // Assert result.Should().BeOfType <ObjectResult>(); citiesDTO[0].Name.ShouldBeEquivalentTo(name); }
public void GetCityWithoutPoi_CityExist_ReturnsCityWithoutPoiDTO() { //Arrange bool includePoi = false; var anyCity = CityFaker.Generate(); var cityWithoutPoiDto = ToDTO.ToCityWithoutPoiDto(anyCity); MockCityRepository.CityExists(anyCity.Id).Returns(true); MockCityRepository.GetCity(anyCity.Id, includePoi).Returns(anyCity); //Action var result = CityController.GetCity(anyCity.Id, includePoi); // Assert result.Should().BeOfType <ObjectResult>() .Which.Value.ShouldBeEquivalentTo(cityWithoutPoiDto); }
public ActionResult <TipoMaquinaDTO> GetTipoMaquinaByDescricao(String descricao) { long id = 0; List <TipoMaquina> listaTipo = _context.TipoMaquinas.ToList(); foreach (TipoMaquina tm in listaTipo) { if (tm.descricao.descricao == descricao) { id = tm.Id; } } TipoMaquina tpm = repo.SelectById(id); if (tpm == null) { return(NotFound()); } return(ToDTO.TipoMaquinaToDTO(tpm)); }
public static bool CapNhatTo(ToDTO T) { return(ToDAO.CapNhatTo(T)); }
public static bool ThemTo(ToDTO T) { return(ToDAO.ThemTo(T)); }
public IEnumerable <ListaMaquinasOperacaoDTO> GetListaMaquinasOperacao() { IEnumerable <ListaMaquinasOperacao> lista = TMORepo.SelectAll(); return(ToDTO.ListaMaquinasOperacaoToDTO(lista)); }
public IEnumerable <LinhaProducaoMaquinaDTO> GetListaLinhaProducaoMaquina() { IEnumerable <LinhaProducaoMaquina> lista = repo.SelectAll(); return(ToDTO.ListaLinhaProducaoMaquinaToDTO(lista)); }
public IEnumerable <TipoMaquinaDTO> GetListaTipoMaquina() { IEnumerable <TipoMaquina> lista = repo.SelectAll(); return(ToDTO.ListaTipoMaquinaToDTO(lista)); }