Пример #1
0
        public async Task <IActionResult> DeletePost([FromRoute] long id)
        {
            var post = await _ctx.Posts.Include(p => p.Author)
                       .Include(p => p.Location)
                       .FirstOrDefaultAsync(p => p.Id == id);

            if (post.Author.Email != _userHelper.Email)
            {
                return(Forbid());
            }

            _ctx.Remove(post.Location);
            _ctx.Remove(post);
            await _ctx.SaveChangesAsync();

            return(Ok());
        }
Пример #2
0
 public void Remove(Domain.Models.Order t)
 {
     Entities.Order dbOrder = mapper.Map(t, context);
     Entities.Order order   = context.Orders.ToList().Find(o => o.GetHashCode() == dbOrder.GetHashCode());
     if (order is not null)
     {
         context.Remove(order);
         context.SaveChanges();
     }
 }
 public void Remove(Domain.Models.Crust t)
 {
     Entities.Crust dbCrust = mapper.Map(t);
     Entities.Crust crust   = context.Crusts.ToList().Find(c => c.CrustType == dbCrust.CrustType);
     if (crust is not null)
     {
         context.Remove(crust);
         context.SaveChanges();
     }
 }
 public void Remove(Domain.Models.Topping t)
 {
     Entities.Topping dbTopping = mapper.Map(t);
     Entities.Topping topping   = context.Toppings.ToList().Find(t => t.ToppingType == dbTopping.ToppingType);
     if (topping is not null)
     {
         context.Remove(topping);
         context.SaveChanges();
     }
 }
Пример #5
0
 public void Remove(Domain.Models.Size t)
 {
     Entities.Size dbSize = mapper.Map(t, context);
     Entities.Size size   = context.Sizes.ToList().Find(s => s.SizeType == dbSize.SizeType);
     if (size is not null)
     {
         context.Remove(size);
         context.SaveChanges();
     }
 }
        public void Remove(AStore t)
        {
            Store existingStore = context.Stores.ToList().Find(store => store.Name.Equals(t.Name));

            if (existingStore is not null)
            {
                context.Remove(existingStore);
                context.SaveChanges();
            }
        }
        public void Remove(APizza t)
        {
            Pizza dbPizza = mapper.Map(t);
            Pizza pizza   = context.Pizzas.ToList().Find(p => p.GetHashCode() == dbPizza.GetHashCode());

            if (pizza is not null)
            {
                context.Remove(pizza);
                context.SaveChanges();
            }
        }