public void Delete(ClothesColorDTO entity) { ClothesColor color = new ClothesColor(); color = Mapper.Map <ClothesColorDTO, ClothesColor>(entity); using (var db = new ClothesDbContext()) { var deletedColor = db.Colors.Where(x => x.Name == color.Name).FirstOrDefault(); db.Colors.Remove(deletedColor); db.SaveChanges(); } }
public void Update(ClothesColorDTO entity) { ClothesColor color = new ClothesColor(); color = Mapper.Map <ClothesColorDTO, ClothesColor>(entity); using (var db = new ClothesDbContext()) { //Todo: Add custom logic to check if another object like this exist in the data base. var newColors = db.Colors.Where(col => col.Id == color.Id).FirstOrDefault(); newColors = color; db.SaveChanges(); } }
public void Create(ClothesColorDTO entity) { ClothesColor color = new ClothesColor(); color = Mapper.Map <ClothesColorDTO, ClothesColor>(entity); using (var db = new ClothesDbContext()) { if (entity != null) { db.Colors.Add(color); db.SaveChanges(); } } }