public Guardarropa ObtenerGuardarropaPorId(int id)
 {
     try
     {
         GuardarropaEntity    guardarropa = _dbContext.Guardarropas.Find(id);
         PrendasRepositorio   repo        = new PrendasRepositorio();
         ICollection <Prenda> prendas     = repo.GetPrendasGuardarropa(id);
         Guardarropa          model       = GuardarropaMapper.MapModel(guardarropa);
         model.Prendas = prendas;
         return(model);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Example #2
0
        public static Guardarropa MapModel(GuardarropaEntity entidad)
        {
            ICollection <Prenda> prendas = new List <Prenda>();

            if (entidad.Prendas != null)
            {
                foreach (var x in entidad.Prendas)
                {
                    prendas.Add(PrendaMapper.MapModel(x));
                }
            }

            return(new Guardarropa()
            {
                GuardarropaId = entidad.GuardarropaId,
                PrendasMaximas = entidad.PrendasMaximas,
                Usuarios = entidad.Usuarios,
                Prendas = prendas
            });
        }
 public Guardarropa CrearGuardarropa(Guardarropa guardarropa)
 {
     try
     {
         GuardarropaEntity entidad = GuardarropaMapper.MapEntity(guardarropa);
         _dbContext.Guardarropas.Add(entidad);
         _dbContext.SaveChanges();
         PrendasRepositorio repo = new PrendasRepositorio();
         foreach (var x in guardarropa.Prendas)
         {
             repo.AddPrenda(x);
         }
         foreach (var x in guardarropa.Usuarios)
         {
             AgregarGuardarropa(x, guardarropa.GuardarropaId);
         }
         return(guardarropa);
     }
     catch (Exception e)
     {
         throw e;
     }
 }