public void ShouldAddVendor() { var newVendor = new Mock <IAddVendorModel>(); newVendor.Setup(x => x.Company).Returns("test vendor"); newVendor.Setup(x => x.NamespacePrefix).Returns("http://www.test.com/"); newVendor.Setup(x => x.ContactName).Returns("test user"); newVendor.Setup(x => x.ContactEmailAddress).Returns("*****@*****.**"); int id = 0; Scoped <IUsersContext>(usersContext => { var command = new AddVendorCommand(usersContext); id = command.Execute(newVendor.Object); id.ShouldBeGreaterThan(0); }); Transaction(usersContext => { var vendor = usersContext.Vendors.Single(v => v.VendorId == id); vendor.VendorName.ShouldBe("test vendor"); vendor.VendorNamespacePrefixes.First().NamespacePrefix.ShouldBe("http://www.test.com/"); vendor.Users.Single().FullName.ShouldBe("test user"); vendor.Users.Single().Email.ShouldBe("*****@*****.**"); }); }
public void ShouldAddVendorIfMultipleNamespacePrefixes() { var newVendor = new Mock <IAddVendorModel>(); var namespacePrefixes = new List <string> { "http://www.test1.com/", "http://www.test2.com/", "http://www.test3.com/" }; newVendor.Setup(x => x.Company).Returns("test vendor"); newVendor.Setup(x => x.NamespacePrefixes).Returns(namespacePrefixes.ToDelimiterSeparated()); newVendor.Setup(x => x.ContactName).Returns("test user"); newVendor.Setup(x => x.ContactEmailAddress).Returns("*****@*****.**"); int id = 0; Scoped <IUsersContext>(usersContext => { var command = new AddVendorCommand(usersContext); id = command.Execute(newVendor.Object).VendorId; id.ShouldBeGreaterThan(0); }); Transaction(usersContext => { var vendor = usersContext.Vendors.Single(v => v.VendorId == id); vendor.VendorName.ShouldBe("test vendor"); vendor.VendorNamespacePrefixes.Select(x => x.NamespacePrefix).ShouldBe(namespacePrefixes); vendor.Users.Single().FullName.ShouldBe("test user"); vendor.Users.Single().Email.ShouldBe("*****@*****.**"); }); }
public async Task <IResult> Handle(Validator validator, AddVendorCommand addVendorCommand, IMapper mapper, Request request) { await validator.GuardAsync(request); var addedVendor = addVendorCommand.Execute(request); var model = mapper.Map <VendorModel>(addedVendor); return(AdminApiResponse <VendorModel> .Created(model, "Vendor", $"/{FeatureConstants.Vendors}/{model.VendorId}")); }
public GlobalSettingsController(IMapper mapper , IGetVendorsQuery getVendorsQuery , AddVendorCommand addVendorCommand , DeleteVendorCommand deleteVendorCommand , IGetVendorByIdQuery getVendorByIdQuery , EditVendorCommand editVendorCommand , ICloudOdsSettingsService cloudOdsSettingsService , ITabDisplayService tabDisplayService , IGetClaimSetsByApplicationNameQuery getClaimSetsByApplicationNameQuery , GetAdminAppUsersQuery getAdminAppUsersQuery) { _mapper = mapper; _getVendorsQuery = getVendorsQuery; _addVendorCommand = addVendorCommand; _deleteVendorCommand = deleteVendorCommand; _getVendorByIdQuery = getVendorByIdQuery; _editVendorCommand = editVendorCommand; _cloudOdsSettingsService = cloudOdsSettingsService; _tabDisplayService = tabDisplayService; _getClaimSetsByApplicationNameQuery = getClaimSetsByApplicationNameQuery; _getAdminAppUsersQuery = getAdminAppUsersQuery; }
public async Task <IActionResult> AddNewVendor([FromBody] AddVendorCommand data) { var res = await Mediator.Send(data); return(Ok(res)); }
public async Task <IActionResult> AddVendor([FromBody] AddVendorCommand command) { var vendor = await _mediator.Send(command); return(Ok(vendor)); }