Beispiel #1
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Delete(int id)
        {
            user_model model = new user_model();
            var        user  = model.Login_Info.Where(p => p.UserId == id);

            model.Login_Info.Remove(user.ToList()[0]);
            model.SaveChanges();
            return(View("Index", model.Login_Info.ToList()));
        }
Beispiel #2
0
        public async Task <Dto> Handle(Command request, CancellationToken cancellationToken)
        {
            var userdata = new user_model
            {
                name     = request.data.Attributes.name,
                username = request.data.Attributes.username,
                email    = request.data.Attributes.email,
                password = request.data.Attributes.password,
                address  = request.data.Attributes.address
            };

            konteks.user.Add(userdata);
            await konteks.SaveChangesAsync(cancellationToken);

            var user   = konteks.user.First(x => x.username == request.data.Attributes.username);
            var target = new TargetCommand()
            {
                Id = user.id, Email_destination = user.email
            };
            var client  = new HttpClient();
            var command = new PostCommand()
            {
                Title   = "hello world",
                Message = "you think this is hello world, but it was me dio",
                Type    = "email",
                From    = 2,
                Target  = new List <TargetCommand>()
                {
                    target
                }
            };

            var attributes = new Data <PostCommand>()
            {
                Attributes = command
            };

            var httpContent = new RequestData <PostCommand>()
            {
                data = attributes
            };

            var jsonObj = JsonConvert.SerializeObject(httpContent);
            var content = new StringContent(jsonObj, Encoding.UTF8, "application/json");
            await client.PostAsync("http://localhost:2000/notification", content);


            return(new Dto
            {
                message = "user posted",
                success = true
            });
        }
Beispiel #3
0
        private void DownloadUsers()
        {
            List <user_model> users = new List <user_model>();

            for (int i = 0; i < 55; i++)
            {
                user_model um = new user_model();

                um.username = "******" + i;
                um.password = "******" + i;
                users.Add(um);
            }

            SQLiteDatabase.InsertTestUser(users);
        }
Beispiel #4
0
        public async Task <Dto> Handle(Command request, CancellationToken cancellationToken)
        {
            var userdata = new user_model
            {
                name     = request.data.Attributes.name,
                username = request.data.Attributes.username,
                email    = request.data.Attributes.email,
                password = request.data.Attributes.password,
                address  = request.data.Attributes.address
            };

            konteks.user.Add(userdata);
            await konteks.SaveChangesAsync(cancellationToken);

            var user   = konteks.user.First(x => x.username == request.data.Attributes.username);
            var target = new TargetCommand()
            {
                Id = user.id, Email_destination = user.email
            };
            var client  = new HttpClient();
            var command = new PostCommand()
            {
                Title   = "hjfrhftcutcuc6ello rtyxdrtxdye4ty",
                Message = "you think this is hello world, but it was me dio",
                Type    = "email",
                From    = 56,
                Target  = new List <TargetCommand>()
                {
                    target
                }
            };

            var attributes = new Data <PostCommand>()
            {
                Attributes = command
            };

            var httpContent = new RequestData <PostCommand>()
            {
                data = attributes
            };

            var jsonObj = JsonConvert.SerializeObject(httpContent);

            //var content = new StringContent(jsonObj, Encoding.UTF8, "application/json");
            //await client.PostAsync("http://localhost:2000/notification",content);

            //sender
            var factory = new ConnectionFactory()
            {
                HostName = "localhost"
            };

            using (var connection = factory.CreateConnection())
                using (var channel = connection.CreateModel())
                {
                    channel.ExchangeDeclare("userDataExchange", "fanout");
                    //channel.QueueDeclare(queue: "userData", durable: true, exclusive: false, autoDelete: false, arguments: null);
                    var Body       = Encoding.UTF8.GetBytes(jsonObj);
                    var properties = channel.CreateBasicProperties();
                    properties.Persistent = true;
                    channel.BasicPublish(exchange: "", routingKey: "userData", basicProperties: null, body: Body);
                    Console.WriteLine("User data has been forwarded");
                    Console.ReadLine();
                }
            Console.ReadLine();



            return(new Dto
            {
                message = "user posted",
                success = true
            });
        }