Exemplo n.º 1
0
        public static bool Delete(Products item)
        {
            try
            {
                Products pr = db.Products.Single(p => p.Id == item.Id);
                CloudinaryRepository.DeleteFile(pr.ImageLink);
                db.Products.Remove(pr);
                db.SaveChanges();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        public static bool Edit(Products item, string image)
        {
            try
            {
                Products pr = db.Products.Single(p => p.Id == item.Id);

                if (image != null)
                {
                    CloudinaryRepository.DeleteFile(pr.ImageLink);
                    pr.ImageLink = image;
                }

                pr.Name        = item.Name;
                pr.Price       = item.Price;
                pr.Description = item.Description;
                db.SaveChanges();

                return(true);
            }
            catch
            {
                return(false);
            }
        }