示例#1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors();
            services.AddMvc();

            IoCManager.ConfigureServices(services);
            AutoMapperRegister.Register();

            services.AddSwaggerGen();
            services.ConfigureSwaggerGen(options =>
            {
                options.SwaggerDoc("v1", new Info {
                    Title = "PASTEL API", Version = "v1"
                });
            });
        }
示例#2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors();
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
            services.AddAutoMapper();

            IoCManager.ConfigureServices(services);
            AutoMapperRegister.Register();

            services.AddSwaggerGen();
            services.ConfigureSwaggerGen(opt =>
            {
                opt.SwaggerDoc("v1", new Info {
                    Title = "Jogador API", Version = "v1"
                });
            });
        }
示例#3
0
        static void Main(string[] args)
        {
            AutoMapperRegister.Register();

            UserService userService = new UserService();

            Console.WriteLine("======GetUserInfoById======");
            var userInfo = userService.GetUserInfoById(1);

            Console.WriteLine(userInfo.ToString());

            Console.WriteLine("======GetAllUser======");
            var userInfos = userService.GetAllUser();

            userInfos.ForEach(userinfo =>
            {
                Console.WriteLine(userinfo.ToString());
            });


            UserDTO userDto = new UserDTO
            {
                Name = "new add",
                Age  = 89
            };


            bool insertResult = userService.AddUser(userDto);

            if (!insertResult)
            {
                Console.WriteLine("Insert Failed !!!");
            }
            else
            {
                Console.WriteLine("======afterAdduserInfos======");
                var afterAdduserInfos = userService.GetAllUser();

                afterAdduserInfos.ForEach(userinfo =>
                {
                    Console.WriteLine(userinfo.ToString());
                });
            }


            userDto.Id   = 7;
            userDto.Name = "update";

            bool updateResult = userService.UpdateUser(userDto);

            if (!updateResult)
            {
                Console.WriteLine("Update Failed !!!");
            }
            else
            {
                Console.WriteLine("======afterUpdateuserInfos======");
                var afterUpdateuserInfos = userService.GetAllUser();

                afterUpdateuserInfos.ForEach(userinfo =>
                {
                    Console.WriteLine(userinfo.ToString());
                });
            }

            bool deleteResult = userService.DeleteUserInfoById(4);

            if (!updateResult)
            {
                Console.WriteLine("Delete Failed !!!");
            }
            else
            {
                Console.WriteLine("======afterDeleteuserInfos======");
                var afterDeleteuserInfos = userService.GetAllUser();

                afterDeleteuserInfos.ForEach(userinfo =>
                {
                    Console.WriteLine(userinfo.ToString());
                });
            }


            Console.ReadKey();
        }