Example #1
0
 public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> suspensionState)
 {
     if (suspensionState.Any())
     {
     }
     RundeH = (RundeHeader)parameter;
     if (RundeH.RundeId > 0)
     {
         TopTekst      = "Ret runde";
         Runde         = new Runde();
         Runde.RundeId = RundeH.RundeId;
         Runde.Sted    = RundeH.Sted;
         Runde.Dato    = RundeH.Dato;
         Runde.Bem     = RundeH.Bem;
         Runde.PuljeId = RundeH.PuljeId;
         Runde.Point1  = RundeH.Point1;
         Runde.Point2  = RundeH.Point2;
         Runde.Point3  = RundeH.Point3;
         Runde.Point4  = RundeH.Point4;
     }
     else
     {
         Runde = new Runde()
         {
             Dato = DateTime.Now
         };
         Runde.PuljeId = RundeH.PuljeId;
         TopTekst      = "Opret ny runde";
     }
     await Task.CompletedTask;
 }
Example #2
0
        public async Task <bool> RetRundeAsync(Runde retRunde)
        {
            if (await AuthenticateUser())
            {
                try
                {
                    await App.mobileServiceClient.InvokeApiAsync("Runde", JToken.FromObject(retRunde), HttpMethod.Put, null);
                }
                catch (MobileServiceInvalidOperationException ex)
                {
                    if (ex.Response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
                    {
                        App.passwordVault.Remove(App.passwordCredentials);
                        await AuthenticateUser();

                        await App.mobileServiceClient.InvokeApiAsync("Runde", JToken.FromObject(retRunde), HttpMethod.Put, null);
                    }
                }
                catch (Exception ex)
                {
                    string mess = ex.ToString();
                }
            }
            else
            {
                MessageDialog dlg = new MessageDialog("Fejl ved authentication!");
                await dlg.ShowAsync();
            }
            return(true);
        }
Example #3
0
        public bool DeleteRunde(int?Id)
        {
            Runde runde = ctx.Runder.Find(Id);

            ctx.Runder.Remove(runde);
            ctx.SaveChanges();
            return(true);
        }
Example #4
0
        public void RunderDelete(Runde item)
        {
            conn.Open();
            SqlCommand cmd = new SqlCommand();

            cmd = new SqlCommand("delete Runder where SpilId = " + item.SpilId + " and RundeNr = " + item.RundeNr + " ", conn);

            cmd.ExecuteNonQuery();
            conn.Close();
        }
Example #5
0
 public async Task <ActionResult <Runde> > PostRunde(Runde item)
 {
     //publish runden
     Publish.Runde(item);
     //tilføj item til context.runder
     //  _context.Runder.Add(item);
     //vent på det er gemt
     //await _context.SaveChangesAsync();
     return(CreatedAtAction(nameof(GetRunde), new { id = item.Id }, item));
 }
Example #6
0
        void SubscribeRunde(IModel channel)
        {
            channel.ExchangeDeclare(exchange: "Runde", type: "fanout");

            var queueName = channel.QueueDeclare().QueueName;

            channel.QueueBind(queue: queueName,
                              exchange: "Runde",
                              routingKey: "");


            var consumer = new EventingBasicConsumer(channel);

            consumer.Received += (model, ea) =>
            {
                var body    = ea.Body;
                var message = Encoding.UTF8.GetString(body);

                Runde item = Newtonsoft.Json.JsonConvert.DeserializeObject <Runde>(message);
                using (var scope = scopeFactory.CreateScope())
                {
                    var   _context    = scope.ServiceProvider.GetRequiredService <RundeContext>();
                    Runde sidsterunde = _context.Runder.Last();
                    item.Id = sidsterunde.Id + 1;
                    //tilføj item til context.runder
                    _context.Runder.Add(item);
                    //vent på det er gemt
                    _context.SaveChangesAsync();
                }
            };
            channel.BasicConsume(queue: queueName,
                                 autoAck: true,
                                 consumer: consumer);

            /*
             * channel.QueueDeclare(queue: "Opret",
             *                   durable: true,
             *                   exclusive: false,
             *                   autoDelete: false,
             *                   arguments: null);
             *
             * channel.BasicQos(prefetchSize: 0, prefetchCount: 1, global: false);*/
            /*
             * var consumer = new EventingBasicConsumer(channel);
             * consumer.Received += (model, ea) =>
             * {
             *  var body = ea.Body;
             *  var message = Encoding.UTF8.GetString(body);
             *  Console.WriteLine(" [x] Received {0}", message);
             * };
             * channel.BasicConsume(queue: "Opret",
             *                   autoAck: true,
             *                   consumer: consumer);*/
        }
Example #7
0
        public async Task <IActionResult> PutRunde(long id, Runde item)
        {
            if (id != item.Id)
            {
                return(BadRequest());
            }

            _context.Entry(item).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }
Example #8
0
        private static List <Runde> GetMasterDbRunder()
        {
            List <Runde> RundeListe = new List <Runde>();

            SqlConnection conn = MainDbConnection.GetConn();

            conn.Open();

            string        selectSQL = "SELECT * FROM Runder;";
            SqlCommand    com       = new SqlCommand(selectSQL, conn);
            SqlDataReader myReader  = com.ExecuteReader();// NB new method used here

            try
            {                           // loop through the ResultSet, one tuple at the time:
                while (myReader.Read()) // first advance the curser to the next tuple.
                {
                    Runde r = new Runde();
                    r.Id      = myReader.GetInt32(0);
                    r.SpilId  = myReader.GetInt32(1);
                    r.RundeNr = myReader.GetInt32(2);
                    r.Melder  = myReader.GetInt32(3);
                    r.Melding = myReader.GetInt32(4);
                    try
                    {
                        r.PlusId = myReader.GetInt32(5);
                    }
                    catch { }
                    try {
                        r.Makker = myReader.GetInt32(6);
                    }
                    catch { }
                    r.Vundet   = myReader.GetBoolean(7);
                    r.Beloeb   = Convert.ToDouble(myReader.GetDecimal(8));
                    r.Spiller1 = myReader.GetInt32(9);
                    r.Spiller2 = myReader.GetInt32(10);
                    r.Spiller3 = myReader.GetInt32(11);
                    r.Spiller4 = myReader.GetInt32(12);

                    RundeListe.Add(r);
                }
            }
            finally
            {
                myReader.Close(); // close nicely the ResultSet
            }

            return(RundeListe);
        }
Example #9
0
        void SubscribeRunde(IModel channel, SqlQueryInsert queryInsert)
        {
            channel.ExchangeDeclare(exchange: "Runde", type: "fanout");

            var queueName = channel.QueueDeclare().QueueName;

            channel.QueueBind(queue: queueName,
                              exchange: "Runde",
                              routingKey: "");


            var consumer = new EventingBasicConsumer(channel);

            consumer.Received += (model, ea) =>
            {
                var body    = ea.Body;
                var message = Encoding.UTF8.GetString(body);

                Runde item = Newtonsoft.Json.JsonConvert.DeserializeObject <Runde>(message);
                queryInsert.RunderInsert(item);
            };
            channel.BasicConsume(queue: queueName,
                                 autoAck: true,
                                 consumer: consumer);

            /*
             * channel.QueueDeclare(queue: "Opret",
             *                   durable: true,
             *                   exclusive: false,
             *                   autoDelete: false,
             *                   arguments: null);
             *
             * channel.BasicQos(prefetchSize: 0, prefetchCount: 1, global: false);*/
            /*
             * var consumer = new EventingBasicConsumer(channel);
             * consumer.Received += (model, ea) =>
             * {
             *  var body = ea.Body;
             *  var message = Encoding.UTF8.GetString(body);
             *  Console.WriteLine(" [x] Received {0}", message);
             * };
             * channel.BasicConsume(queue: "Opret",
             *                   autoAck: true,
             *                   consumer: consumer);*/
        }
Example #10
0
        public void RunderInsert(Runde item)
        {
            conn.Open();
            SqlCommand cmd = new SqlCommand();

            if (item.PlusId == 0)
            {
                item.PlusId = null;
            }


            cmd = new SqlCommand("INSERT INTO Runder " +
                                 "Values (" + item.SpilId + "," + item.RundeNr + "," + item.Melder + "," + item.Melding + "," +
                                 item.PlusId + "," + item.Makker + ",'" + item.Vundet + "'," + item.Beloeb + "," +
                                 item.Spiller1 + "," + item.Spiller2 + "," + item.Spiller3 + "," + item.Spiller4 + ")", conn);

            cmd.ExecuteNonQuery();
            conn.Close();
        }
Example #11
0
        public async Task <IActionResult> DeleteTodoItem(int spilid, int rundenr)
        {
            /*var runde = await _context.Runder.FindAsync(spilid,rundenr);
             *
             * if (runde == null)
             * {
             *   return NotFound();
             * }
             *
             * _context.Runder.Remove(runde);
             * await _context.SaveChangesAsync();*/
            Runde runde = new Runde();

            runde.SpilId  = spilid;
            runde.RundeNr = rundenr;

            Publish.Delete(runde);
            return(NoContent());
        }
Example #12
0
 public bool PutRunde(Runde retRunde)
 {
     ctx.Entry(retRunde).State = System.Data.Entity.EntityState.Modified;
     ctx.SaveChanges();
     return(true);
 }
Example #13
0
 public bool PostRunde(Runde nyRunde)
 {
     ctx.Runder.Add(nyRunde);
     ctx.SaveChanges();
     return(true);
 }