public void EditarGuardarropa(Guardarropa guardarropa) { try { var entidad = GuardarropaMapper.MapEntity(guardarropa); _dbContext.Guardarropas.Update(entidad); _dbContext.SaveChanges(); } catch (Exception e) { throw e; } }
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; } }
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; } }