//Metodo valida los datos que recibe por parametro //para posteriormente insertarlos o actualizarlos desde DAL public void agregarServicio(ENT.Servicio servicio) { DAL.Servicio DalServicio = new DAL.Servicio(); //try //{ if (servicio.Impuesto <= 0) { throw new Exception("Impuesto del servicio requerido"); } if (servicio.Precio <= 0) { throw new Exception("Precio del servicio requerido"); } if (servicio.pServicio == string.Empty) { throw new Exception("Tipo de servicio requerido"); } if (servicio.Descripcion == string.Empty) { throw new Exception("Debes ingresar una descripciĆ³n"); } if (servicio.DiasPromedio <= 0) { throw new Exception("Debes agregar las horas promedio de este servicio"); } if (servicio.Id <= 0) { DalServicio.agregarservicio(servicio); if (DalServicio.Error) { throw new Exception("Error al agregar el servicio " + DalServicio.ErrorMsg); } } else { DalServicio.actualizarServicio(servicio); if (DalServicio.Error) { throw new Exception("Error al actualizar el servicio " + DalServicio.ErrorMsg); } } //} //catch (Exception ex) //{ // throw ex; //} }
//Metodo valida los datos y comprueva cualquier error //para posteriormente pasarlos a DAL public void eliminarServicio(ENT.Servicio servicio) { DAL.Servicio DalServicio = new DAL.Servicio(); try { if (servicio.Id <= 0) { throw new Exception("Debes de seleccionar un servicio"); } DalServicio.borrarservicio(servicio); if (DalServicio.Error) { throw new Exception("Error al eliminar el servicio"); } } catch (Exception ex) { throw ex; } }