using System.Collections.ObjectModel; using Entidades; namespace Modelo { public sealed class RepositorioOrdenDeCompra : RepositorioBase { override public bool Add(OrdenDeCompra t) { bool ret = false; try { almacen.Add(t); ret = true; } catch (Exception) { throw; } return ret; } override public bool Mod(OrdenDeCompra t) { bool ret = false; try { var ordenAModificar = almacen.FindIndex(x => x.Id == t.Id); if (ordenAModificar > -1) { almacen[ordenAModificar] = t; ret = true; } } catch (Exception) { throw; } return ret; } override public bool Del(OrdenDeCompra t) { bool ret = false; try { var ordenAEliminar = almacen.Find(x => x.Id == t.Id); if (ordenAEliminar != null) { almacen.Remove(ordenAEliminar); ret = true; } } catch (Exception) { throw; } return ret; } public ReadOnlyCollection MostrarDetalles(OrdenDeCompra orden) { return orden.MostrarDetalles(); } public bool MarcarEntregado(OrdenDeCompra orden) { bool ret = false; if (orden == null) return ret; if (orden.Id < 0) return ret; if (orden.Entregado == false) return ret; var ordenAModificar = almacen.FindIndex(x => x.Id == orden.Id); if (ordenAModificar > -1) { almacen[ordenAModificar].Entregado = true; ret = true; } return ret; } } }