Example #1
0
        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();
            }
        }
Example #2
0
        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();
            }
        }
Example #3
0
        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();
                }
            }
        }