public void DeleteGame(DeleteBindingModel dbm)
        {
            var game = this.Context.Games.Find(dbm.Id);

            this.Context.Games.Remove(game);
            this.Context.SaveChanges();
        }
        public IActionResult Delete(HttpResponse response, HttpSession session, DeleteBindingModel dbm)
        {
            User activeUser = AuthenticationManager.GetAuthenticatedUser(session.Id);

            if (activeUser == null)
            {
                this.Redirect(response, "/users/login");
                return(null);
            }
            if (!activeUser.IsAdmin)
            {
                this.Redirect(response, "/store/home");
                return(null);
            }

            this.service.DeleteGame(dbm);
            this.Redirect(response, "/games/all");
            return(null);
        }
        public async static Task <BaseResultModel> DeleteEmpresaBindingModel(this IEntityService <Empresa> service, DeleteBindingModel model)
        {
            var mongoObj = await service.MongoService.GetMongoObject <EmpresaClienteMongoModel>(model.Id);

            if (mongoObj == null)
            {
                return new BaseResultModel {
                           IsValid = false, StatusCode = 404
                }
            }
            ;

            var entityId = int.Parse(mongoObj.ParentId);
            var entity   = await service.GetSingleAsync(entityId);

            if (entity == null)
            {
                return new BaseResultModel {
                           IsValid = false, StatusCode = 404
                }
            }
            ;

            if (!string.IsNullOrEmpty(mongoObj.Modulo) && !mongoObj.Modulo.Equals(EnumUtility.GetEnumText(Modulo.Gestor)))
            {
                return new BaseResultModel {
                           IsValid = false, StatusCode = 400, Message = string.Format("Esta empresa não pode ser excluída porque foi inserida pelo módulo {0}", mongoObj.Modulo)
                }
            }
            ;

            await service.MongoService.DeleteMongoObject <EmpresaClienteMongoModel>(mongoObj.Id);

            await service.DeleteAsync(entity.Id);

            return(new BaseResultModel {
                IsValid = true, StatusCode = 200
            });
        }