Esempio n. 1
0
        public void ShouldDeleteVendorWithApplication()
        {
            var newVendor = new Vendor {
                VendorName = "test vendor"
            };
            var newApplication = new Application {
                ApplicationName = "test application", OperationalContextUri = OperationalContext.DefaultOperationalContextUri
            };

            newVendor.Applications.Add(newApplication);
            Save(newVendor);
            var vendorId      = newVendor.VendorId;
            var applicationId = newApplication.ApplicationId;

            applicationId.ShouldBeGreaterThan(0);

            Scoped <IUsersContext>(usersContext =>
            {
                var deleteApplicationCommand = new DeleteApplicationCommand(usersContext);
                var deleteVendorCommand      = new DeleteVendorCommand(usersContext, deleteApplicationCommand);
                deleteVendorCommand.Execute(vendorId);
            });

            Transaction(usersContext => usersContext.Vendors.Where(v => v.VendorId == vendorId).ToArray()).ShouldBeEmpty();
            Transaction(usersContext => usersContext.Applications.Where(a => a.ApplicationId == applicationId).ToArray()).ShouldBeEmpty();
        }
Esempio n. 2
0
        public void ShouldDeleteVendorWithUser()
        {
            var newVendor = new Vendor {
                VendorName = "test vendor"
            };
            var newUser = new VendorUser {
                FullName = "test user"
            };

            newVendor.Users.Add(newUser);
            Save(newVendor);
            var vendorId = newVendor.VendorId;
            var userId   = newUser.UserId;

            userId.ShouldBeGreaterThan(0);


            Scoped <IUsersContext>(usersContext =>
            {
                var deleteVendorCommand = new DeleteVendorCommand(usersContext, null);
                deleteVendorCommand.Execute(vendorId);
            });

            Transaction(usersContext => usersContext.Vendors.Where(v => v.VendorId == vendorId).ToArray()).ShouldBeEmpty();
            Transaction(usersContext => usersContext.Users.Where(u => u.UserId == userId).ToArray()).ShouldBeEmpty();
        }
        public ActionResult DeleteVendor(DeleteVendorModel model)
        {
            var vendor = _getVendorByIdQuery.Execute(model.VendorId);

            if (vendor.IsSystemReservedVendor())
            {
                return(JsonError("This Vendor is required for proper system function and may not be deleted"));
            }

            _deleteVendorCommand.Execute(model.VendorId);
            return(RedirectToActionJson <GlobalSettingsController>(x => x.Vendors(), "Vendor removed successfully"));
        }
 public ActionResult DeleteVendor(DeleteVendorModel model)
 {
     try
     {
         _deleteVendorCommand.Execute(model.VendorId);
     }
     catch (Exception ex)
     {
         return(JsonError(ex.Message));
     }
     return(RedirectToActionJson <GlobalSettingsController>(x => x.Vendors(), "Vendor removed successfully"));
 }
Esempio n. 5
0
        public void ShouldDeleteVendor()
        {
            var newVendor = new Vendor();

            Save(newVendor);
            var vendorId = newVendor.VendorId;

            var deleteVendorCommand = new DeleteVendorCommand(TestContext, null);

            deleteVendorCommand.Execute(vendorId);
            TestContext.Vendors.Where(v => v.VendorId == vendorId).ShouldBeEmpty();
        }
Esempio n. 6
0
        public void ShouldDeleteVendor()
        {
            var newVendor = new Vendor();

            Save(newVendor);
            var vendorId = newVendor.VendorId;

            Scoped <IUsersContext>(usersContext =>
            {
                var deleteVendorCommand = new DeleteVendorCommand(usersContext, null);
                deleteVendorCommand.Execute(vendorId);
            });

            Transaction(usersContext => usersContext.Vendors.Where(v => v.VendorId == vendorId).ToArray()).ShouldBeEmpty();
        }
Esempio n. 7
0
 public Task <IResult> Handle(DeleteVendorCommand deleteVendorCommand, int id)
 {
     deleteVendorCommand.Execute(id);
     return(Task.FromResult(AdminApiResponse.Deleted("Vendor")));
 }