示例#1
0
        public Cloth Update(Cloth clothChange)
        {
            var cloth = context.Clothers.Attach(clothChange);

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