示例#1
0
 public ParkingVM(Model.Parking initParking)
 {
     parking = initParking;
 }
示例#2
0
        //ParkingRegister
        public void AddParking(object parametar)
        {
            using (var db = new dbContext.Parking())
            {
                var pm = new Model.ParkingModel(brojp);
                db.pmodels.Add(pm);
                db.SaveChanges();

                var lc = new Model.Location
                {
                    //x = ?;
                    //y = ?;
                };
                db.location.Add(lc);
                db.SaveChanges();

                int tmp = 0;
                foreach (Model.Account ac in acc)
                {
                    if (ac.Email() == _email)
                    {
                        tmp = ac.id;
                    }
                }
                var pa = new Model.Parking(tmp, parkingname, grad, drzava, lc.id, (float)Double.Parse(cijena), Int32.Parse(starttime), Int32.Parse(endtime), Int32.Parse(kapacitet), Int32.Parse(freeplaces), pm.id, 0);
                db.parking.Add(pa);
                db.SaveChanges();
                IMobileServiceTable <AzureTabela.Parking> userTableObj = App.MobileService.GetTable <AzureTabela.Parking>();
                try
                {
                    AzureTabela.Parking par = new AzureTabela.Parking();
                    par.Accid      = tmp;
                    par.Name       = parkingname;
                    par.City       = grad;
                    par.Country    = drzava;
                    par.pLocation  = lc.id;
                    par.Price      = (float)Double.Parse(cijena);
                    par.startTime  = Int32.Parse(starttime);
                    par.endTime    = Int32.Parse(endtime);
                    par.Capacity   = Int32.Parse(kapacitet);
                    par.freePlaces = Int32.Parse(freeplaces);
                    par.Model      = pm.id;
                    par.approved   = 0;
                    userTableObj.InsertAsync(par);
                    MessageDialog msgDialog = new MessageDialog("Uspješno ste unijeli novi parking.");
                    msgDialog.ShowAsync();
                }
                catch (Exception ex)
                {
                    MessageDialog msgDialogError = new MessageDialog("Error : " + ex.ToString());
                    msgDialogError.ShowAsync();
                }
                var mess = new Model.Message("Add parking Request...", tmp, DateTime.Now);
                db.inbox.Add(mess);
                db.SaveChanges();
            }



            firstname = string.Empty;
            lastname  = string.Empty;
            Email     = string.Empty;
            pasw      = string.Empty;
            cb        = false;
            rpasw     = string.Empty;
        }