public bool RegistrarRecibo(BE.UI.VacacionRecibo uiVacacionRecibo) { try { int rowsAffected = 0; var daVacacionRecibo = new DA.VacacionRecibo(); BE.VacacionRecibo beVacacionRecibo = UiReciboToBeRecibo(uiVacacionRecibo); if (beVacacionRecibo.IdVacacionRecibo == 0) { rowsAffected = daVacacionRecibo.Insertar(ref beVacacionRecibo); uiVacacionRecibo.Id = beVacacionRecibo.IdVacacionRecibo; } else { rowsAffected = daVacacionRecibo.Actualizar(beVacacionRecibo); } return(rowsAffected > 0); } catch (Exception ex) { throw ex; } }
public BE.UI.VacacionRecibo ObtenerRecibo(int idVacacion) { try { BE.UI.VacacionRecibo uiVacacionRecibo = null; BE.VacacionRecibo beVacacionRecibo = new DA.VacacionRecibo().Obtener(idVacacion); if (beVacacionRecibo != null) { uiVacacionRecibo = BeReciboToUiRecibo(beVacacionRecibo); } return(uiVacacionRecibo); } catch (Exception ex) { throw ex; } }
private BE.UI.VacacionRecibo BeReciboToUiRecibo(BE.VacacionRecibo beVacacionRecibo) { try { var uiVacacionRecibo = new BE.UI.VacacionRecibo(); uiVacacionRecibo.Id = beVacacionRecibo.IdVacacionRecibo; //uiVacacionRecibo.IdVacacion = beVacacionRecibo.IdVacacion; //Obtener las propiedades que sean publicas y se puedan escribir var lstPropertiesInfosBE = beVacacionRecibo.GetType().GetProperties() .Where(x => x.CanWrite == true && x.PropertyType.IsPublic == true) .ToList(); //Obtener las propuedades que sean publicas y se puedan escribir var lstPropertiesInfosUI = uiVacacionRecibo.GetType().GetProperties() .Where(x => x.CanWrite == true && x.PropertyType.IsPublic == true) .ToList(); foreach (PropertyInfo propertyInfoUI in lstPropertiesInfosUI) { var propertyName = propertyInfoUI.Name; PropertyInfo propertyInfoBE = lstPropertiesInfosBE.Where(x => x.Name == propertyName).FirstOrDefault(); if (propertyInfoBE != null) { propertyInfoUI.SetValue(uiVacacionRecibo, propertyInfoBE.GetValue(beVacacionRecibo)); } } return(uiVacacionRecibo); } catch (Exception ex) { throw ex; } }