Exemplo n.º 1
0
        public Cloth Update(Cloth clothChange)
        {
            var cloth = context.Clothers.Attach(clothChange);

            cloth.State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            context.SaveChanges();
            return(clothChange);
        }
Exemplo n.º 2
0
        public Cloth Delete(int id)
        {
            Cloth cloth = context.Clothers.Find(id);

            if (cloth != null)
            {
                if (cloth.PhotoPath != null)
                {
                    string filePath = System.IO.Path.Combine(_webHostEnvironment.WebRootPath, "images", cloth.PhotoPath);
                    System.IO.File.Delete(filePath);
                }
                context.Clothers.Remove(cloth);
                context.SaveChanges();
            }
            return(cloth);
        }
Exemplo n.º 3
0
 public Cloth Update(Cloth clothChange)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 4
0
 public Cloth Add(Cloth cloth)
 {
     context.Clothers.Add(cloth);
     context.SaveChanges();
     return(cloth);
 }
Exemplo n.º 5
0
 public Cloth Add(Cloth cloth)
 {
     cloth.Id = _clothList.Max(e => e.Id) + 1;
     _clothList.Add(cloth);
     return(cloth);
 }