Exemplo n.º 1
0
        public IActionResult CreateOgr([FromBody] Ogranzition ogranzition)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid model object"));
            }
            if (communication.Call("rpc_queue", "", ogranzition).Equals("true"))
            {
                FContextFactory.Create(Configuration["TenantOrganzition"].Replace("{{tenantId}}", ogranzition.NameOgranzition));
                return(Ok("Success"));
            }

            return(Ok("Error"));
        }
        public bool Edit_Ogranzition(string id, Ogranzition _Ogranzition)
        {
            var findId_Ogranzition = _context.Ogranzition.Find(id);

            if (findId_Ogranzition != null)
            {
                findId_Ogranzition.NameOgranzition = _Ogranzition.NameOgranzition;
                _context.SaveChanges();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
 public IActionResult Edit_Ogranzition([FromBody] Ogranzition _ogranzition, string id)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest("Invalid model object"));
     }
     try
     {
         return(Ok(ogranzitionRepos.Edit_Ogranzition(id, _ogranzition)));
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
Exemplo n.º 4
0
        public void Register()
        {
            channel.QueueDeclare(queue: "rpc_queue", durable: false, exclusive: false, autoDelete: false, arguments: null);
            channel.BasicQos(0, 1, false);
            var consumer = new EventingBasicConsumer(channel);

            channel.BasicConsume(queue: "rpc_queue", consumer: consumer);
            Console.WriteLine("Rabbitmq lang nghe ProptechPlus");

            consumer.Received += (model, ea) =>
            {
                string response = null;

                var body       = ea.Body;
                var props      = ea.BasicProperties;
                var replyProps = channel.CreateBasicProperties();
                replyProps.CorrelationId = props.CorrelationId;

                try
                {
                    var         message     = Encoding.UTF8.GetString(body);
                    Ogranzition ogranzition = JsonConvert.DeserializeObject <Ogranzition>(message);
                    Console.WriteLine(ogranzition.NameOgranzition + "000000000000");
                    //int n = int.Parse(message);
                    if (OgranzitionCommunicationReponsitory.CreateCatalogOgranzition(ogranzition))
                    {
                        response = "true";
                    }
                    else
                    {
                        response = "false";
                    }
                }
                catch (Exception)
                {
                    response = "false";
                }
                finally
                {
                    var responseBytes = Encoding.UTF8.GetBytes(response);
                    channel.BasicPublish(exchange: "", routingKey: props.ReplyTo, basicProperties: replyProps, body: responseBytes);
                    channel.BasicAck(deliveryTag: ea.DeliveryTag, multiple: false);
                }
            };
        }
        public string Call(string routingKey, string exchange, Ogranzition message)

        {
            string json         = JsonConvert.SerializeObject(message);
            var    messageBytes = Encoding.UTF8.GetBytes(json);

            channel.BasicPublish(
                exchange: exchange,
                routingKey: routingKey,
                basicProperties: props,
                body: messageBytes);

            channel.BasicConsume(
                consumer: consumer,
                queue: replyQueueName,
                autoAck: true);

            return(respQueue.Take());;
        }
Exemplo n.º 6
0
        public static bool CreateCatalogOgranzition(Ogranzition ogranzition)
        {
            if (findById(ogranzition.IdOgranzition))
            {
                Console.WriteLine("-----------------find");
                CatalogOgranzition catalogOgranzition = new CatalogOgranzition
                {
                    IdOgranzition   = ogranzition.IdOgranzition,
                    NameOgranzition = ogranzition.NameOgranzition
                };
                Console.WriteLine("-----------------chuan bi save");
                catalog.CatalogOgranzition.Add(catalogOgranzition);
                catalog.SaveChanges();

                Console.WriteLine("-----------------fish");

                return(true);
            }
            else
            {
                return(false);
            }
        }
 public bool Create_Ogranzition(Ogranzition _Ogranzition)
 {
     return(Genaral_Add_Edit_Remove <Ogranzition> .Add_ObjInDatabase(_Ogranzition, _context));
 }
 public async Task <IActionResult> Get_Ogranzition([FromBody] Ogranzition ogranzition)
 {
     return(Ok(communication.Call("rpc_queue", "", ogranzition)));
 }