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

            cloth.State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            context.SaveChanges();
            return(clothChange);
        }
Esempio 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);
        }
Esempio n. 3
0
 public Cloth Update(Cloth clothChange)
 {
     throw new NotImplementedException();
 }
Esempio n. 4
0
 public Cloth Add(Cloth cloth)
 {
     context.Clothers.Add(cloth);
     context.SaveChanges();
     return(cloth);
 }
Esempio n. 5
0
 public Cloth Add(Cloth cloth)
 {
     cloth.Id = _clothList.Max(e => e.Id) + 1;
     _clothList.Add(cloth);
     return(cloth);
 }