Ejemplo n.º 1
0
        public async void LoadParking()
        {
            try
            {
                using (var db = new SPARK.Model.SPARKDbContext())
                {
                    IMobileServiceTable <Azure.Parking> userTableObj = App.MobileService.GetTable <Azure.Parking>();
                    List <Azure.Parking> lista = await App.MobileService.GetTable <Azure.Parking>().ToListAsync();

                    Azure.Parking u = lista.Find(x => x.id == IDparkinga);
                    p                = new Parking();
                    p.Address        = u.Address;
                    p.Name           = u.Name;
                    p.Id             = Convert.ToInt32(u.id);
                    p.Zone           = u.Zone;
                    p.Price          = u.Price;
                    p.CoordX         = u.CoordX;
                    p.CoordY         = u.CoordY;
                    p.Capacity       = u.Capacity;
                    p.NumTakenSpaces = u.NumTakenSpaces;
                    p.WorkingHours   = new KeyValuePair <DateTime, DateTime>(Convert.ToDateTime(u.WorkingFrom), Convert.ToDateTime(u.WorkingTo));
                    p.TodaysProfit   = u.TodaysProfit;
                    p.NumTakenSpaces = u.NumTakenSpaces;
                    p.MonthlyProfit  = u.MonthlyProfit;
                    p.NumTakenSpaces = u.NumTakenSpaces;
                    p.MinCredits     = Convert.ToInt32(u.MinCredits);
                }
            }
            catch (Exception izuzetak)
            {
                var dialog1 = new MessageDialog(izuzetak.Message);
                dialog1.Commands.Add(new UICommand {
                    Label = "Ok"
                });
                await dialog1.ShowAsync();
            }
        }
Ejemplo n.º 2
0
        public static void Initialize(SPARKDbContext context)
        {
            if (!context.Parkings.Any())
            {
                Parking p = new Parking();
                p.Id             = 0;
                p.Address        = "Zmaja od Bosne";
                p.Name           = "Defaultni parking";
                p.Zone           = 1;
                p.Price          = 2;
                p.CoordX         = 43.865;
                p.CoordY         = 18.413;
                p.Capacity       = 10;
                p.NumTakenSpaces = 20;
                p.WorkingHours   = new KeyValuePair <DateTime, DateTime>(Convert.ToDateTime("1.1.2017"), Convert.ToDateTime("5.2.2017"));
                p.TodaysProfit   = 100;
                p.MonthlyProfit  = 1000;
                p.NumTakenSpaces = 50;
                p.MinCredits     = 10;
                context.Parkings.AddRange(p);
                context.SaveChanges();
            }

            if (!context.User.Any())
            {
                User u = new User();
                u.Id       = 0;
                u.Username = "******";
                u.Password = "******";
                u.Name     = "Rifet";
                u.Surname  = "Auspuh";
                u.Email    = "*****@*****.**";
                context.User.AddRange(u);
                context.SaveChanges();
            }

            if (!context.Owner.Any())
            {
                Owner u = new Owner();
                u.Id       = 0;
                u.Username = "******";
                u.Password = "******";
                u.Name     = "Imeneko";
                u.Surname  = "Prezimeneko";
                u.Email    = "*****@*****.**";
                context.Owner.AddRange(u);
                context.SaveChanges();
            }

            if (!context.PaymentMethods.Any())
            {
                PaymentMethod u = new PaymentMethod();
                u.Id          = 0;
                u.Name        = "Kartica";
                u.Description = "Placanje kreditnom karticom";
                u.Packages    = new List <KeyValuePair <int, double> > {
                    new KeyValuePair <int, double>(1, 20)
                };

                context.PaymentMethods.AddRange(u);
                context.SaveChanges();
            }
        }