public async Task <IActionResult> Update([FromRoute] string id, [FromBody] UpdateAuctionViewModel viewModel)
        {
            var auctionId = IdentityBase.FromExistingId <AuctionId>(id);
            var command   = new UpdateAuctionCommand(auctionId, viewModel.Name, viewModel.AuctionDate);
            await _commandBus.ExecuteAsync(command);

            return(Ok());
        }
        public async Task <IActionResult> RemoveItem([FromRoute] string auctionId, [FromRoute] string itemName)
        {
            var id      = IdentityBase.FromExistingId <AuctionId>(auctionId);
            var command = new RemoveAuctionItemCommand(id, itemName);
            await _commandBus.ExecuteAsync(command);

            return(NoContent());
        }
예제 #3
0
 public static void BindService(grpc::ServiceBinderBase serviceBinder, IdentityBase serviceImpl)
 {
     serviceBinder.AddMethod(__Method_CreateUser, serviceImpl == null ? null : new grpc::UnaryServerMethod <global::Google.Showcase.V1Beta1.CreateUserRequest, global::Google.Showcase.V1Beta1.User>(serviceImpl.CreateUser));
     serviceBinder.AddMethod(__Method_GetUser, serviceImpl == null ? null : new grpc::UnaryServerMethod <global::Google.Showcase.V1Beta1.GetUserRequest, global::Google.Showcase.V1Beta1.User>(serviceImpl.GetUser));
     serviceBinder.AddMethod(__Method_UpdateUser, serviceImpl == null ? null : new grpc::UnaryServerMethod <global::Google.Showcase.V1Beta1.UpdateUserRequest, global::Google.Showcase.V1Beta1.User>(serviceImpl.UpdateUser));
     serviceBinder.AddMethod(__Method_DeleteUser, serviceImpl == null ? null : new grpc::UnaryServerMethod <global::Google.Showcase.V1Beta1.DeleteUserRequest, global::Google.Protobuf.WellKnownTypes.Empty>(serviceImpl.DeleteUser));
     serviceBinder.AddMethod(__Method_ListUsers, serviceImpl == null ? null : new grpc::UnaryServerMethod <global::Google.Showcase.V1Beta1.ListUsersRequest, global::Google.Showcase.V1Beta1.ListUsersResponse>(serviceImpl.ListUsers));
 }
예제 #4
0
 public static grpc::ServerServiceDefinition BindService(IdentityBase serviceImpl)
 {
     return(grpc::ServerServiceDefinition.CreateBuilder()
            .AddMethod(__Method_CreateUser, serviceImpl.CreateUser)
            .AddMethod(__Method_GetUser, serviceImpl.GetUser)
            .AddMethod(__Method_UpdateUser, serviceImpl.UpdateUser)
            .AddMethod(__Method_DeleteUser, serviceImpl.DeleteUser)
            .AddMethod(__Method_ListUsers, serviceImpl.ListUsers).Build());
 }
        public async Task <IActionResult> AddItem([FromRoute] string auctionId,
                                                  [FromBody] AddAuctionItemViewModel viewModel)
        {
            var id      = IdentityBase.FromExistingId <AuctionId>(auctionId);
            var item    = new AuctionItem(viewModel.Name, viewModel.Donor, viewModel.Description, viewModel.Quantity);
            var command = new AddAuctionItemCommand(id, item);
            await _commandBus.ExecuteAsync(command);

            return(CreatedAtRoute("GetAuctionItems", new { auctionId }, null));
        }
예제 #6
0
        public void InheritanceTest()
        {
            Employee e = new Employee(1, "Damon", "Allison", 20, "allidam");

            Assert.IsAssignableFrom <Employee>(e);
            Assert.IsAssignableFrom <Person>(e);
            Assert.IsAssignableFrom <IdentityBase>(e);
            Assert.IsAssignableFrom <IIdentity>(e);

            Person       p  = e;
            IdentityBase ib = p;
            IIdentity    i  = ib;

            Assert.Equal("Allison, Damon", e.Name);
            Assert.Equal("Allison, Damon", p.Name);
            Assert.Equal("Damon Allison", (string)p);

            Assert.Equal(e.Id, p.Id);
            Assert.Equal(p.Id, ib.Id);
            Assert.Equal(ib.Id, i.Id);

            // Note that we have three references to the same object.
            Assert.True(Object.ReferenceEquals(e, p));
            Assert.True(Object.ReferenceEquals(p, i));
            Assert.True(Object.ReferenceEquals(i, ib));

            // `is` determines if an object is of a given type. Generally, you want
            // to avoid having to downcast an object. You should be able to work with
            // an object as it's declared in the current scope. If you need to downcast,
            // consider changing the declaration of the function to require the specific
            // type you are looking for.
            Assert.True(p is IIdentity);
            Assert.True(p is IdentityBase);
            Assert.NotNull(p as Employee); // Downcast. This should be avoided.

            // `as` goes a step beyond `is`. If the object is of a given type, it will
            // convert the type and return a reference to the object as the target type
            // or `null` if the cast is not valid.
            //
            // C#'s' type checker is smart enough to know that p (Person) cannot be converted
            // to a string. Therefore, we cast to `object` to fool the type checker.
            string s = (string)p;

            Assert.Equal("Damon Allison", (string)p);
            Assert.Equal("Damon Allison", (string)e);

            object obj = (object)p;

            Assert.IsAssignableFrom <Employee>(obj);
            Assert.NotNull(obj as Employee);
            Assert.NotNull(obj as Person);
            Assert.NotNull(obj as IdentityBase);
            Assert.NotNull(obj as IIdentity);
        }
        protected void CheckAuditPattern(IdentityBase model, bool created = false)
        {
            string userId = TryGetUserId();

            if (created)
            {
                model.CreatedOn = DateTime.Now;
                model.CreatedBy = userId;
            }
            model.ChangedOn = DateTime.Now;
            model.ChangedBy = userId;
        }
        public async Task <IActionResult> UpdateItem(
            [FromRoute] string auctionId,
            [FromRoute] string itemName,
            [FromBody] UpdateAuctionItemViewModel viewModel)
        {
            var id      = IdentityBase.FromExistingId <AuctionId>(auctionId);
            var command = new UpdateAuctionItemCommand(
                id,
                itemName,
                viewModel.NewName,
                viewModel.NewDonor,
                viewModel.NewDescription,
                viewModel.NewQuantity);

            await _commandBus.ExecuteAsync(command);

            return(NoContent());
        }
예제 #9
0
 public PrincipalBase(IdentityBase identity)
 {
     IdentityBase = identity;
 }
 protected EntityBase(IdentityBase id) => Id = id;
예제 #11
0
        public void ExecuteSuccess(IdentityBase id)
        {
            ExecuteSuccess();

            this.DomainModelId = id;
        }
 public Person(IdentityBase id) : base(id)
 {
 }
예제 #13
0
 protected static Guid GetPersistId(IdentityBase id)
 {
     return(id.GetPersistId());
 }
예제 #14
0
 protected AggregateRoot(IdentityBase id) : base(id)
 {
 }
예제 #15
0
 public void ExecuteSuccess(IdentityBase id)
 {
     this.ExecuteResult.ExecuteSuccess(id);
 }