/// <summary> /// Eliminar una fuente RSS /// </summary> /// <param name="pRssSourceDTO">fuente RSS que se desea eliminar</param> public void Remove(RssSourceDTO pRssSourceDTO) { try { var asociatedBanners = iUnitOfWork.RssSourceRepository.GetBannersWithSource(pRssSourceDTO.Id); if (asociatedBanners.ToList().Count == 0) { log.Info("Eliminando fuente RSS"); RssSource RssSource = iUnitOfWork.RssSourceRepository.Get(pRssSourceDTO.Id); iUnitOfWork.RssSourceRepository.Remove(RssSource); iUnitOfWork.Complete(); log.Info("fuente RSS eliminada con exito"); } else { throw new Exception("No se puede eliminar la fuente RSS ya que esta siendo usada por banners"); } } catch (ArgumentNullException e) { log.Error("Error al eliminar fuente RSS: " + e.Message); throw new ArgumentException(); } }
public void RssSourceController_NewSource() { // Arrange string lTitle = "Noticias de futbol ESPN"; string lDescription = "Noticias del ámbito futbolistico, siendo su fuente ESPN (en inglés)"; string lURL = "http://soccernet.espn.go.com/rss/news"; ManageSourceHandler lController = new ManageSourceHandler(); RssSourceDTO lResult; RssSourceDTO lDto; // Act lDto = new RssSourceDTO() { Title = lTitle, Description = lDescription, URL = lURL }; lDto.Id = lController.AddSource(lDto); // Assert lResult = lController.GetSource(lDto.Id); AssertAreEqual(lDto, lResult); }
void AssertAreEqual(RssSourceDTO lDto, RssSourceDTO lResult) { Assert.AreEqual(lDto.Id, lResult.Id); Assert.AreEqual(lDto.Title, lResult.Title); Assert.AreEqual(lDto.Description, lResult.Description); Assert.AreEqual(lDto.URL, lResult.URL); }
private void dgvSources_CellContentClick(object sender, DataGridViewCellEventArgs e) { DataGridViewRow row = dgvSources.CurrentRow; RssSourceDTO lSource = (RssSourceDTO)dgvSources.GetItem(row.Index); RssSourceView ventana = new RssSourceView(); ventana.View(lSource); }
void IAddModifyViewForm.Add(IDTO pNewRSSSource) { this.txtTitle.Text = String.Empty; this.txtDescription.Text = String.Empty; this.txtURL.Text = String.Empty; this.Text = "Agregar nueva FuenteRSS"; this.iOriginalRSSSource = (RssSourceDTO)pNewRSSSource; }
private void selectRssSourceButton_Click(object sender, EventArgs e) { if (rssSourcesGridView.SelectedRows.Count == 0) { MetroMessageBox.Show(this, "Primero debe seleccionar una fuente RSS de la lista", "No hay ninguna fuente RSS seleccionada", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } iSelectedRssSource = (RssSourceDTO)rssSourcesGridView.SelectedRows[0].DataBoundItem; DialogResult = DialogResult.OK; Close(); }
public RssSourceDTO GetSource(int pId) { RssSourceDTO lResult = new RssSourceDTO(); iUoW.BeginTransaction(); try { lResult = Mapper.Map <RssSource, RssSourceDTO>(iServ.Read(pId)); } finally { iUoW.Rollback(); } return(lResult); }
public void DeleteSource(RssSourceDTO pDto) { iUoW.BeginTransaction(); try { RssSource lSource = Mapper.Map <RssSourceDTO, RssSource>(pDto); iServ.Delete(pDto.Id); iUoW.Commit(); } catch (Exception) { iUoW.Rollback(); throw; } }
public void ModifySource(RssSourceDTO pDto) { iUoW.BeginTransaction(); try { RssSource lSource = Mapper.Map <RssSourceDTO, RssSource>(pDto); iServ.Update(lSource); iUoW.Commit(); } catch (Exception) { iUoW.Rollback(); throw; } }
public RssSourceForm(RssSourceDTO pRssSource) { InitializeComponent(); if (pRssSource != null) { iRssSourceModel = pRssSource; loadRssSourceInView(); } else { iRssSourceModel = new RssSourceDTO(); iRssSourceModel.RssItems = new List <RssItemDTO>(); } }
public int AddSource(RssSourceDTO pDto) { iUoW.BeginTransaction(); try { RssSource lSource = Mapper.Map <RssSourceDTO, RssSource>(pDto); iServ.Create(lSource); iUoW.Commit(); return(lSource.Id); } catch (Exception) { iUoW.Rollback(); throw; } }
void IAddModifyViewForm.Modify(IDTO pRSSSource) { if (pRSSSource == null) { throw new EntidadNulaException("La fuente RSS indicada es nula"); //TODO excepcion argumentexception creo } else { this.iOriginalRSSSource = (RssSourceDTO)pRSSSource; this.txtTitle.Text = iOriginalRSSSource.Title; this.txtDescription.Text = iOriginalRSSSource.Description; this.txtURL.Text = iOriginalRSSSource.URL; this.Text = "Modificar FuenteRSS"; } }
public void View(RssSourceDTO pRSSSource) { if (pRSSSource == null) { throw new EntidadNulaException("La fuente RSS indicada es nula"); //TODO excepcion argumentexception creo } else { this.txtTitle.Text = pRSSSource.Title; this.txtDescription.Text = pRSSSource.Description; this.txtURL.Text = pRSSSource.URL; this.Text = "Fuente Rss: " + pRSSSource.Title; this.ShowDialog(); } }
/// <summary> /// Obtiene una fuente RSS por su id /// </summary> /// <param name="pId">id de la fuente RSS que se quiere obtener</param> /// <returns></returns> public RssSourceDTO Get(int pId) { try { log.Info("Obteniendo fuente RSS"); var RssSource = iUnitOfWork.RssSourceRepository.Get(pId); log.Info("fuente RSS obtenida con exito"); var RssSourceDTO = new RssSourceDTO(); AutoMapper.Mapper.Map(RssSource, RssSourceDTO); return(RssSourceDTO); } catch (Exception e) { log.Error("Error al obtener fuente RSS: " + e.Message); throw new Exception(); } }
public IList <RssSourceDTO> ListSources() { IList <RssSourceDTO> lResult = new List <RssSourceDTO>(); iUoW.BeginTransaction(); try { foreach (var rss in iServ.GetAll()) { RssSourceDTO lDto = Mapper.Map <RssSource, RssSourceDTO>(rss); lResult.Add(lDto); } } finally { iUoW.Rollback(); } return(lResult); }
private void btnAdd_Click(object sender, EventArgs e) { try { using (var controller = this.iFactory.GetController <ManageSourceHandler>()) { RssSourceDTO lRssSource = new RssSourceDTO(); AgregarModificarFuenteRSS ventana = new AgregarModificarFuenteRSS(this.iFactory); if (this.dgvRSSSource.Add(ventana, lRssSource)) { controller.AddSource(lRssSource); this.CargarDataGrid(); } } } catch (Exception) { throw; } }
/// <summary> /// Crea una fuente RSS /// </summary> /// <param name="pRssSourceDTO">fuente RSS que se quiere crear</param> public void Create(RssSourceDTO pRssSourceDTO) { ///Mapea el DTO a un objecto RssSource var rssSource = new RssSource(); AutoMapper.Mapper.Map(pRssSourceDTO, rssSource); try { log.Info("Guardando fuente RSS"); this.iUnitOfWork.RssSourceRepository.Add(rssSource); this.iUnitOfWork.Complete(); log.Info("fuente RSS creada con exito"); } catch (ArgumentException e) { log.Error("Error al crear fuente RSS: " + e.Message); throw new ArgumentException(); } }
private void dgvRSSSource_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e) { try { using (var controller = this.iFactory.GetController <ManageSourceHandler>()) { DataGridViewRow row = dgvRSSSource.CurrentRow; RssSourceDTO lRssSource = dgvRSSSource.GetItem(row.Index); AgregarModificarFuenteRSS ventana = new AgregarModificarFuenteRSS(this.iFactory); if (this.dgvRSSSource.Modify(ventana, lRssSource)) { controller.ModifySource(lRssSource); this.CargarDataGrid(); } } } catch (Exception) { throw; } }
/// <summary> /// Actualiza una fuente RSS /// </summary> /// <param name="pRssSourceDTO">fuente RSS que se desea actualizar</param> public void Update(RssSourceDTO pRssSourceDTO) { ///fuente RSS actualizada var RssSource = new RssSource(); AutoMapper.Mapper.Map(pRssSourceDTO, RssSource); try { //fuente RSS anterior log.Info("Actualizando fuente RSS"); iUnitOfWork.RssSourceRepository.Update(RssSource); //Guardando los cambios iUnitOfWork.Complete(); } catch (Exception e) { log.Error("Error al actualizar fuente RSS: " + e.Message); throw new Exception(); } }