public IEnumerable <string> Get()
        {
            var result = QueriesOrCommands;

            QueriesOrCommands.Add("/events");

            return(result);
        }
Exemple #2
0
        public bool DeleteBySearch(string value)
        {
            QueriesOrCommands.Add(nameof(DeleteContactBySearchCommand));

            var command = new DeleteContactBySearchCommand {
                Value = value
            };

            return(DeleteContactBySearch(command));
        }
Exemple #3
0
        public IEnumerable <Contact> Search(string value)
        {
            QueriesOrCommands.Add(nameof(SearchContactsQuery));

            var query = new SearchContactsQuery {
                Value = value
            };

            return(SearchContacts(query));
        }
Exemple #4
0
        public bool Delete(int id)
        {
            QueriesOrCommands.Add(nameof(DeleteContactCommand));

            var command = new DeleteContactCommand {
                Id = id
            };

            return(DeleteContact(command));
        }
Exemple #5
0
        public int Get(int number1, int number2)
        {
            QueriesOrCommands.Add(nameof(AddNumbersQuery));

            var query = new AddNumbersQuery {
                Number1 = number1, Number2 = number2
            };

            return(query.Number1 + query.Number2);
        }
Exemple #6
0
        public Contact Get(int id)
        {
            QueriesOrCommands.Add(nameof(GetContactByIdQuery));

            var query = new GetContactByIdQuery {
                Id = id
            };

            return(GetContactById(query));
        }
        public int Get(string @operator, int number1, int number2)
        {
            QueriesOrCommands.Add(nameof(CalculateQuery));

            var query = new CalculateQuery {
                Operator = @operator, Number1 = number1, Number2 = number2
            };

            return(Calculate(query));
        }
Exemple #8
0
        public IEnumerable <Contact> Get()
        {
            QueriesOrCommands.Add(nameof(GetContactsQuery));

            var query  = new GetContactsQuery();
            var result = GetContacts(query);

            GetContactsQueryCount++;

            return(result);
        }
Exemple #9
0
        public static void Main(string[] args)
        {
            WebHost.CreateDefaultBuilder(args)
            .ConfigureServices(s => s.AddRouting())
            .ConfigureServices(s => s.AddMvc())
            .ConfigureServices(s =>
            {
                s.AddSwaggerGen(c =>
                {
                    c.SwaggerDoc("v1", new Info {
                        Title = "My API", Version = "v1"
                    });
                    c.GenerateTagadaSwaggerDoc();
                });
            })
            .Configure(app =>
            {
                app.Map("/api")
                .Get("/hello", () => "Hello world!")
                .Get("/add/{number1}/{number2}", (AddNumbersQuery query) => query.Number1 + query.Number2)
                .Get("/calculate/{operator}", Calculate)
                .Get("/contacts", GetContacts)
                .Get("/contacts/search", SearchContacts)
                .Get("/contacts/{id}", GetContactById)
                .Post("/contacts", CreateContact)
                .Put("/contacts", UpdateContact)
                .Delete("/contacts/search", DeleteContactBySearch)
                .Delete("/contacts/{id}", DeleteContact)
                .Get("/events", () => QueriesOrCommands)
                .Get("/count", () => GetContactsQueryCount)
                .AfterEach(routeResult => QueriesOrCommands.Add(routeResult.Input?.GetType().Name ?? routeResult.Path))
                .AfterEach <GetContactsQuery>(_ => GetContactsQueryCount++)
                .AddSwagger()
                .Use();

                app.UseSwaggerUI(c =>
                {
                    c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
                });
            })
            .Build()
            .Run();
        }
Exemple #10
0
        public Contact Put([FromBody] UpdateContactCommand command)
        {
            QueriesOrCommands.Add(nameof(UpdateContactCommand));

            return(UpdateContact(command));
        }
Exemple #11
0
        public Contact Post([FromBody] CreateContactCommand command)
        {
            QueriesOrCommands.Add(nameof(CreateContactCommand));

            return(CreateContact(command));
        }
Exemple #12
0
 public int Get()
 {
     QueriesOrCommands.Add("/count");
     return(GetContactsQueryCount);
 }
Exemple #13
0
 public string Get()
 {
     QueriesOrCommands.Add("/hello");
     return("Hello world!");
 }