Exemple #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,BrojMjesta,BrojStola,Dostupan")] Sto sto)
        {
            if (id != sto.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(sto);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StoExists(sto.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(sto));
        }
Exemple #2
0
        public IHttpActionResult ProvjeriRezervacije()
        {
            var rezervisaniStolovi =
                ctx.Rezervacija.Where(x => !x.IsDeleted && (x.datumVrijemeOd.Day == DateTime.Now.Day && x.datumVrijemeOd.Month == DateTime.Now.Month && x.datumVrijemeOd.Year == DateTime.Now.Year) &&
                                      (((DateTime.Now.Hour - x.datumVrijemeOd.Hour) == 0) &&
                                       ((DateTime.Now.Minute - x.datumVrijemeOd.Minute) <= 15 && (DateTime.Now.Minute - x.datumVrijemeOd.Minute) >= -30))).ToList()
                .Select(x => new StoloviRezervacijaVM()
            {
                StoId          = x.StoId,
                IsSlobodan     = x.Sto.IsSlobodan,
                RedniBrojStola = x.Sto.RedniBroj,
                RezervacijaId  = x.Id,
                DatumOd        = x.datumVrijemeOd
            })
                .ToList();

            foreach (var x in rezervisaniStolovi)
            {
                Sto sto = ctx.Stolovi.Where(y => y.Id == x.StoId).SingleOrDefault();
                ctx.Entry(sto).Entity.IsSlobodan = false;
                ctx.SaveChanges();
            }
            var slobodniStolovi = ctx.Rezervacija.Where(x => x.Sto.IsSlobodan == true).ToList();

            foreach (var x in slobodniStolovi)
            {
                Sto sto = ctx.Stolovi.Where(y => y.Id == x.StoId).SingleOrDefault();
                ctx.Entry(sto).Entity.IsSlobodan = true;
                var rez = ctx.Rezervacija.Where(y => y.Id == x.Id).FirstOrDefault();
                ctx.Rezervacija.Remove(rez);
                ctx.SaveChanges();
            }
            return(Ok());
        }
Exemple #3
0
        public async Task <Sto> DodajSto(Sto s)
        {
            var sto = unitOfWork.StoRepository.Add(s);
            await unitOfWork.Commit();

            return(sto);
        }
 // Start is called before the first frame update
 void Start()
 {
     pausespin = false;
     Pau.SetActive(true);
     Sto.SetActive(false);
     gameover.SetActive(false);
 }
Exemple #5
0
        public static Sto Restore()
        {
            Sto network = new Sto();

            using (var context = new STODbContext())
            {
                var servicesQuery = context.Services
                                    .Include(s => s.material);

                foreach (Service service in servicesQuery)
                {
                    network.serviceList.AddService(service);
                }

                var accountQuery = context.Accounts
                                   .Include(a => a.customer);

                foreach (Account acc in accountQuery)
                {
                    network.Accounts.Add(acc);
                }

                var ordersQuery = context.Orders;

                foreach (Order o in ordersQuery)
                {
                    network.Orders.Add(o);
                }
            }

            return(network);
        }
Exemple #6
0
        public async Task AzurirajSto(Sto s)
        {
            Sto sto = unitOfWork.StoRepository.Get(s.Id);

            if (sto != null)
            {
                unitOfWork.StoRepository.Update(s);
                await unitOfWork.Commit();
            }
        }
Exemple #7
0
        public async Task ObrisiSto(int id)
        {
            Sto s = unitOfWork.StoRepository.Get(id);

            if (s != null)
            {
                unitOfWork.StoRepository.Delete(s);
                await unitOfWork.Commit();
            }
        }
Exemple #8
0
        public static void Main(string[] args)
        {
            Test testModelGenerator = new Test();
            Sto  network1           = testModelGenerator.generate();

            STOOrm.Save(network1);

            Sto network2 = STOOrm.Restore();

            compareNetworks(network1, network2);
        }
Exemple #9
0
        public async Task <IActionResult> Create([Bind("Id,BrojMjesta,BrojStola,Dostupan")] Sto sto)
        {
            if (ModelState.IsValid)
            {
                _context.Add(sto);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(sto));
        }
Exemple #10
0
 public static void Save(Sto network)
 {
     using (var context = new STODbContext())
     {
         context.Database.Delete();
         context.Orders.AddRange(network.Orders);
         context.Accounts.AddRange(network.Accounts);
         context.Services.AddRange(network.serviceList.Services);
         context.SaveChanges();
     }
 }
Exemple #11
0
        public IHttpActionResult OznaciSto([FromBody] int Id)
        {
            Sto sto = ctx.Stolovi.Where(x => x.RedniBroj == Id).SingleOrDefault();

            if (sto != null)
            {
                ctx.Entry(sto).Entity.IsSlobodan = false;
                ctx.SaveChanges();
                return(Ok());
            }

            return(BadRequest());
        }
 public void Buttons(string paneladi)
 {
     if (paneladi == "starting")
     {
         pausespin = true;
         Sto.SetActive(true);
         Pau.SetActive(false);
     }
     if (paneladi == "stoping")
     {
         pausespin = false;
         Pau.SetActive(true);
         Sto.SetActive(false);
     }
 }
Exemple #13
0
        public async Task <IActionResult> Reserved([Bind("Id")] Sto sto)
        {
            if (ModelState.IsValid)
            {
                var stoId    = sto.Id;
                var stariSto = await _context.Sto.FindAsync(stoId);

                stariSto.Dostupan = 1;
                _context.Sto.Update(stariSto);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Reserved", "Sto"));
            }
            return(View(sto));
        }
Exemple #14
0
        private static void compareNetworks(Sto network1, Sto network2)
        {
            StringWriter writer1          = new StringWriter(new StringBuilder());
            var          reportGenerator1 = new Report(writer1, network1);

            reportGenerator1.generate();

            StringWriter writer2          = new StringWriter(new StringBuilder());
            var          reportGenerator2 = new Report(writer2, network2);

            reportGenerator2.generate();

            String report1Content = writer1.ToString();
            String report2Content = writer2.ToString();

            Console.WriteLine(report1Content);
            Console.WriteLine(report2Content);
            Console.WriteLine(report1Content.Equals(report2Content) ? "PASSED: Models match" : "FAILED: Models mismatch");
            Console.ReadKey();
            //DbMappingViewCache mv = new DbMappingViewCache);
            //Console.WriteLine(mv.GetView("CodeFirstDatabase.Account"));
        }
Exemple #15
0
 public async Task AzurirajStolove(List <Sto> stolovi)
 {
     if (stolovi.Count > 0)
     {
         List <Sto> result = new List <Sto>();
         foreach (Sto s in stolovi)
         {
             Sto noviSto = new Sto
             {
                 Id        = s.Id,
                 BrojMesta = s.BrojMesta,
                 Oznaka    = s.Oznaka,
                 X         = s.X,
                 Y         = s.Y,
                 KonobarId = s.KonobarId,
                 Slobodan  = s.Slobodan
             };
             result.Add(noviSto);
         }
         unitOfWork.StoRepository.UpdateRange(result);
         await unitOfWork.Commit();
     }
 }
Exemple #16
0
        public async Task <Sto> ZauzmiIliOslobodiSto(string sifra, int idStola)
        {
            Sto s = unitOfWork.StoRepository.FindWithIncludes(x => x.Id == idStola, x => x.Konobar).FirstOrDefault();

            if (s != null)
            {
                s.Slobodan = !s.Slobodan;
                if (s.Slobodan == true)
                {
                    s.Sifra = null;
                }
                else
                {
                    s.Sifra = sifra;
                }
                var sto = unitOfWork.StoRepository.Update(s);
                await unitOfWork.Commit();

                sto.Konobar = s.Konobar;
                return(sto);
            }
            throw new ArgumentNullException("Not found");
        }
Exemple #17
0
        public bool ExportCore(Project Proj, string FileName)
        {
            Directory.CreateDirectory(FileName);
            Directory.SetCurrentDirectory(FileName);

            foreach (Basin Bas in Proj.OpenBasins)
            {
                //this feature is totally moot
                //this will be reimplemented in 3.0 better
                //Directory.CreateDirectory(Bas.Name);
                //Directory.SetCurrentDirectory(Bas.Name);

                List <Storm> FlatStorms = Bas.GetFlatListOfStorms();

                foreach (Storm Sto in FlatStorms)
                {
                    using (StreamWriter SW = new StreamWriter(new FileStream($"{Bas.Name}_{Sto.Name}.dat", FileMode.Create)))
                    {
                        // write HURDAT2 Format Header

                        // should probably make this a method at some point
                        string BasAbbreviation    = Bas.Abbreviation;
                        string StormAdvisoryCount = Utilities.PadZero(Sto.NodeList.Count); // this should return an int
                        string StormName          = Sto.Name;

                        string Year = Sto.FormationDate.ToString("yyyy");

                        if (StormName.Length > 19)
                        {
                            Sto.Name = Sto.Name.Substring(0, 19);
                        }

                        int NoOfSpacesBeforeName = 19 - StormName.Length;

                        if (StormAdvisoryCount.Length > 7)
                        {
                            Sto.Name = Sto.Name.Substring(0, 7);
                        }

                        int NoOfSpacesBeforeStormAdvisoryCount = 7 - StormAdvisoryCount.Length;

                        string StDesignation = $"{BasAbbreviation}{StormAdvisoryCount}{Year}";

                        SW.Write(StDesignation);
                        SW.Write(',');

                        for (int i = 0; i < NoOfSpacesBeforeName; i++)
                        {
                            SW.Write(' ');
                        }

                        SW.Write(StormName);
                        SW.Write(',');

                        for (int i = 0; i < NoOfSpacesBeforeStormAdvisoryCount; i++)
                        {
                            SW.Write(' ');
                        }

                        SW.Write(StormAdvisoryCount);
                        SW.Write(',');
                        SW.WriteLine();

                        foreach (Node No in Sto.NodeList)
                        {
                            // this is going to go here, too tired for this

                            //Temporary Code
                            MainWindow MnWindow = (MainWindow)Application.Current.MainWindow;

                            Category Cat = Sto.GetNodeCategory(No, GlobalState.CategoryManager.CurrentCategorySystem);

                            if (Cat == null)
                            {
                                Logging.Log("Export Warning: Skipping node with nonexistent or illegal category");
                                continue;
                            }

                            DateTime NoDate = Sto.GetNodeDate(No.Id);

                            // Write the node date
                            SW.Write(NoDate.ToString("yyyyMMdd"));

                            SW.Write(", ");

                            // Write the node time...
                            SW.Write(NoDate.ToString("HHmm"));

                            SW.Write(", ");

                            int Peak = Sto.GetPeakIntensity();

                            // Write the tag. We will support more of these in future.
                            if (Peak == No.Intensity)
                            {
                                SW.Write(", I, ");
                            }
                            else
                            {
                                SW.Write(",  , ");
                            }

                            string[] CatWords = Cat.Name.Split(' ');

                            // select the last word
                            string Abbv = Cat.GetAbbreviatedCategoryName(Cat.Name, CatWords.Length - 1, 0, 1, true);

                            SW.Write($"{Abbv}, ");

                            Coordinate CD = Proj.SelectedBasin.FromNodePositionToCoordinate(No.Position, VolatileApplicationSettings.WindowSize);

                            // dumb f*****g piece of shit hack because what the f**k is compatibility you f*****g NOAA dumb f***s
                            CD.Coordinates = new Point(CD.Coordinates.X / 10, CD.Coordinates.Y / 10);
                            SW.Write($"{CD.Coordinates.X}{CD.Directions[0].ToString()}, {CD.Coordinates.Y}{CD.Directions[1]}, ");


                            // we don't save this data lol.
                            // yes i could just write the comma
                            SW.Write($"{No.Intensity},   {No.Pressure},  150,  110,   90,  150,   80,   60,   50,   70,   45,   40,   30,   45");

                            if (No.Id != Sto.NodeList.Count - 1)
                            {
                                SW.Write(",");
                            }

                            SW.WriteLine();
                        }
                    }
                }

                Directory.SetCurrentDirectory(FileName);
            }

            Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);

            // on success
            GlobalState.SetCurrentOpenFile(FileName);
            return(true);
        }
Exemple #18
0
        public async Task <Sto> VratiSto(int id)
        {
            Sto result = await unitOfWork.StoRepository.VratiSto(id);

            return(result);
        }
Exemple #19
0
 public async Task <IActionResult> DodajSto([FromBody] Sto s)
 {
     return(new JsonResult(await stoService.DodajSto(s)));
 }
Exemple #20
0
        public async Task <IActionResult> AzurirajSto([FromBody] Sto s)
        {
            await stoService.AzurirajSto(s);

            return(Ok());
        }
Exemple #21
0
        public async Task <IActionResult> OnPostNextAsync()
        {
            string email = HttpContext.Session.GetString("email");

            if (email == null)
            {
                return(RedirectToPage("/Index"));
            }
            Korisnik korisnik = db.Korisnici.Where(kor => kor.eMail == email && kor.tipKorisnika == "Menadzer" && kor.validanNalog == true).FirstOrDefault();

            if (korisnik == null)
            {
                return(RedirectToPage("/Index"));
            }
            Korisnik korBaza = db.Korisnici.Where(korisnik => korisnik.eMail == email).Include(x => x.mojLokal).AsNoTracking().FirstOrDefault();

            if (korBaza == null)
            {
                return(RedirectToPage("/Index"));
            }
            if (noviLokal.Id != korBaza.mojLokal.Id)
            {
                return(RedirectToPage("/Index"));
            }
            int validImageCount = 0;

            if (!string.IsNullOrEmpty(slika1))
            {
                validImageCount++;
            }
            if (!string.IsNullOrEmpty(slika2))
            {
                validImageCount++;
            }
            if (!string.IsNullOrEmpty(slika3))
            {
                validImageCount++;
            }
            if (!string.IsNullOrEmpty(slika4))
            {
                validImageCount++;
            }
            if (!string.IsNullOrEmpty(slika5))
            {
                validImageCount++;
            }

            if (validImageCount < 3 || string.IsNullOrEmpty(glavnaSlika) || !validTableLayout(tableLayout) || !validNoviLokal())
            {
                return(RedirectToPage());
            }
            System.IO.DirectoryInfo di = new DirectoryInfo(Path.Combine(_environment.ContentRootPath, "wwwroot/images/" + folder));

            foreach (FileInfo file in di.GetFiles())
            {
                file.Delete();
            }
            string folderName = folder;
            string fileName   = "";

            try
            {
                if (!string.IsNullOrEmpty(slika1))
                {
                    fileName         = saveBase64AsImage(slika1, folderName);
                    noviLokal.slika1 = "images/" + folderName + "/" + fileName;
                }
                if (!string.IsNullOrEmpty(slika2))
                {
                    fileName         = saveBase64AsImage(slika2, folderName);
                    noviLokal.slika2 = "images/" + folderName + "/" + fileName;
                }
                if (!string.IsNullOrEmpty(slika3))
                {
                    fileName         = saveBase64AsImage(slika3, folderName);
                    noviLokal.slika3 = "images/" + folderName + "/" + fileName;
                }
                if (!string.IsNullOrEmpty(slika4))
                {
                    fileName         = saveBase64AsImage(slika4, folderName);
                    noviLokal.slika4 = "images/" + folderName + "/" + fileName;
                }
                if (!string.IsNullOrEmpty(slika5))
                {
                    fileName         = saveBase64AsImage(slika5, folderName);
                    noviLokal.slika5 = "images/" + folderName + "/" + fileName;
                }
                if (!string.IsNullOrEmpty(glavnaSlika))
                {
                    fileName             = saveBase64AsImage(glavnaSlika, folderName);
                    noviLokal.nazivSlike = "images/" + folderName + "/" + fileName;
                }
            }
            catch (FormatException fe)
            {
                RedirectToPage("/Error?errorCode=" + fe);
            }
            if (noviLokal.openTime.Minute < 15 && noviLokal.openTime.Minute > 0)
            {
                noviLokal.openTime = noviLokal.openTime.AddMinutes(-(noviLokal.openTime.Minute));
            }
            if (noviLokal.openTime.Minute < 30 && noviLokal.openTime.Minute > 15)
            {
                noviLokal.openTime = noviLokal.openTime.AddMinutes(-(noviLokal.openTime.Minute - 15));
            }
            if (noviLokal.openTime.Minute < 45 && noviLokal.openTime.Minute > 30)
            {
                noviLokal.openTime = noviLokal.openTime.AddMinutes(-(noviLokal.openTime.Minute - 30));
            }
            if (noviLokal.openTime.Minute > 45)
            {
                noviLokal.openTime = noviLokal.openTime.AddMinutes(-(noviLokal.openTime.Minute - 45));
            }

            if (noviLokal.closeTime.Minute < 15 && noviLokal.closeTime.Minute > 0)
            {
                noviLokal.closeTime = noviLokal.closeTime.AddMinutes(-(noviLokal.closeTime.Minute));
            }
            if (noviLokal.closeTime.Minute < 30 && noviLokal.closeTime.Minute > 15)
            {
                noviLokal.closeTime = noviLokal.closeTime.AddMinutes(-(noviLokal.closeTime.Minute - 15));
            }
            if (noviLokal.closeTime.Minute < 45 && noviLokal.closeTime.Minute > 30)
            {
                noviLokal.closeTime = noviLokal.closeTime.AddMinutes(-(noviLokal.closeTime.Minute - 30));
            }
            if (noviLokal.closeTime.Minute > 45)
            {
                noviLokal.closeTime = noviLokal.closeTime.AddMinutes(-(noviLokal.closeTime.Minute - 45));
            }
            if (DateTime.Compare(noviLokal.openTime, noviLokal.closeTime) == 0)
            {
                noviLokal.closeTime = noviLokal.closeTime.AddMinutes(-15);
            }



            string stariLayout = "";


            List <Sto> stariStolovi = db.Stolovi.Where(sto => sto.Lokal.Id == noviLokal.Id).ToList();

            for (int i = 0; i < stariStolovi.Count; i++)
            {
                stariLayout = stariLayout + stariStolovi[i].gsX + "`" + stariStolovi[i].gsY + "`" + stariStolovi[i].gsWidth + "`" + stariStolovi[i].gsHeight + "`" + stariStolovi[i].brojMesta + "`" + stariStolovi[i].oznaka;

                if (i != stariStolovi.Count - 1)
                {
                    stariLayout = stariLayout + "~";
                }
            }
            if (String.Compare(stariLayout, tableLayout) != 0)
            {
                int        counter          = 1;
                List <Sto> noviStolovi      = new List <Sto>(tableLayout.Split('~').Length);
                int        objectSeatsCount = 0;
                Sto        noviSto          = new Sto();
                foreach (string num in tableLayout.Split(new char[] { '`', '~' }))
                {
                    if (counter == 1)
                    {
                        noviSto.gsX = int.Parse(num);
                    }
                    else if (counter == 2)
                    {
                        noviSto.gsY = int.Parse(num);
                    }
                    else if (counter == 3)
                    {
                        noviSto.gsWidth = int.Parse(num);
                    }
                    else if (counter == 4)
                    {
                        noviSto.gsHeight = int.Parse(num);
                    }
                    else if (counter == 5)
                    {
                        noviSto.brojMesta = int.Parse(num);
                        objectSeatsCount += int.Parse(num);
                    }
                    else
                    {
                        noviSto.oznaka = num;
                        noviStolovi.Add(noviSto);
                        noviSto = new Sto();
                    }
                    counter = counter % 6 + 1;
                }


                noviLokal.maxKapacitet = objectSeatsCount;


                foreach (Sto sto in stariStolovi)
                {
                    foreach (Rezervacija rez in db.Rezervacije.Where(rezer => rezer.Sto.Id == sto.Id).Include(x => x.Korisnik).ToList())
                    {
                        if (rez.Vreme > DateTime.Now)
                        {
                            string sadrzajMejla = $"Dear {rez.Korisnik.Ime}, \n\n Your reservation at {noviLokal.Naziv} for {rez.Vreme} has been canceled. Sorry for inconvenience.\n\n Check out our website for other places to make reservations at.\n\n\n Table4U";
                            RegisterModel.SendEmail("Table4U", /*rez.Korisnik.eMail*/ "*****@*****.**", "Reservation canceled", sadrzajMejla);
                        }
                        db.Remove(rez);
                    }


                    db.Stolovi.Remove(sto);
                }
                noviLokal.listaStolova = noviStolovi;
            }
            korisnik.mojLokal = noviLokal;


            await db.SaveChangesAsync();

            return(RedirectToPage("/Index"));
        }
Exemple #22
0
        public async Task <IActionResult> OnPostNextAsync()
        {
            if (HttpContext.Session.GetString("email") != null)
            {
                return(RedirectToPage("/Index"));
            }
            int validImageCount = 0;

            if (!string.IsNullOrEmpty(slika1))
            {
                validImageCount++;
            }
            if (!string.IsNullOrEmpty(slika2))
            {
                validImageCount++;
            }
            if (!string.IsNullOrEmpty(slika3))
            {
                validImageCount++;
            }
            if (!string.IsNullOrEmpty(slika4))
            {
                validImageCount++;
            }
            if (!string.IsNullOrEmpty(slika5))
            {
                validImageCount++;
            }

            if (validImageCount < 3 || string.IsNullOrEmpty(glavnaSlika) || !validTableLayout(tableLayout) || !validNoviLokal())
            {
                return(RedirectToPage());
            }

            string folderName = System.Guid.NewGuid().ToString();
            string fileName   = "";

            try
            {
                if (!string.IsNullOrEmpty(slika1))
                {
                    fileName         = saveBase64AsImage(slika1, folderName);
                    noviLokal.slika1 = "images/" + folderName + "/" + fileName;
                }
                if (!string.IsNullOrEmpty(slika2))
                {
                    fileName         = saveBase64AsImage(slika2, folderName);
                    noviLokal.slika2 = "images/" + folderName + "/" + fileName;
                }
                if (!string.IsNullOrEmpty(slika3))
                {
                    fileName         = saveBase64AsImage(slika3, folderName);
                    noviLokal.slika3 = "images/" + folderName + "/" + fileName;
                }
                if (!string.IsNullOrEmpty(slika4))
                {
                    fileName         = saveBase64AsImage(slika4, folderName);
                    noviLokal.slika4 = "images/" + folderName + "/" + fileName;
                }
                if (!string.IsNullOrEmpty(slika5))
                {
                    fileName         = saveBase64AsImage(slika5, folderName);
                    noviLokal.slika5 = "images/" + folderName + "/" + fileName;
                }
                if (!string.IsNullOrEmpty(glavnaSlika))
                {
                    fileName             = saveBase64AsImage(glavnaSlika, folderName);
                    noviLokal.nazivSlike = "images/" + folderName + "/" + fileName;
                }
            }
            catch (FormatException fe)
            {
                RedirectToPage("/Error?errorCode=" + fe);
            }
            if (noviLokal.openTime.Minute < 15 && noviLokal.openTime.Minute > 0)
            {
                noviLokal.openTime = noviLokal.openTime.AddMinutes(-(noviLokal.openTime.Minute));
            }
            if (noviLokal.openTime.Minute < 30 && noviLokal.openTime.Minute > 15)
            {
                noviLokal.openTime = noviLokal.openTime.AddMinutes(-(noviLokal.openTime.Minute - 15));
            }
            if (noviLokal.openTime.Minute < 45 && noviLokal.openTime.Minute > 30)
            {
                noviLokal.openTime = noviLokal.openTime.AddMinutes(-(noviLokal.openTime.Minute - 30));
            }
            if (noviLokal.openTime.Minute > 45)
            {
                noviLokal.openTime = noviLokal.openTime.AddMinutes(-(noviLokal.openTime.Minute - 45));
            }

            if (noviLokal.closeTime.Minute < 15 && noviLokal.closeTime.Minute > 0)
            {
                noviLokal.closeTime = noviLokal.closeTime.AddMinutes(-(noviLokal.closeTime.Minute));
            }
            if (noviLokal.closeTime.Minute < 30 && noviLokal.closeTime.Minute > 15)
            {
                noviLokal.closeTime = noviLokal.closeTime.AddMinutes(-(noviLokal.closeTime.Minute - 15));
            }
            if (noviLokal.closeTime.Minute < 45 && noviLokal.closeTime.Minute > 30)
            {
                noviLokal.closeTime = noviLokal.closeTime.AddMinutes(-(noviLokal.closeTime.Minute - 30));
            }
            if (noviLokal.closeTime.Minute > 45)
            {
                noviLokal.closeTime = noviLokal.closeTime.AddMinutes(-(noviLokal.closeTime.Minute - 45));
            }
            if (DateTime.Compare(noviLokal.openTime, noviLokal.closeTime) == 0)
            {
                noviLokal.closeTime = noviLokal.closeTime.AddMinutes(-15);
            }
            int        counter          = 1;
            List <Sto> noviStolovi      = new List <Sto>(tableLayout.Split('~').Length);
            int        objectSeatsCount = 0;
            Sto        noviSto          = new Sto();

            foreach (string num in tableLayout.Split(new char[] { '`', '~' }))
            {
                if (counter == 1)
                {
                    noviSto.gsX = int.Parse(num);
                }
                else if (counter == 2)
                {
                    noviSto.gsY = int.Parse(num);
                }
                else if (counter == 3)
                {
                    noviSto.gsWidth = int.Parse(num);
                }
                else if (counter == 4)
                {
                    noviSto.gsHeight = int.Parse(num);
                }
                else if (counter == 5)
                {
                    noviSto.brojMesta = int.Parse(num);
                    objectSeatsCount += int.Parse(num);
                }
                else
                {
                    noviSto.oznaka = num;
                    noviStolovi.Add(noviSto);
                    noviSto = new Sto();
                }
                counter = counter % 6 + 1;
            }
            noviLokal.maxKapacitet = objectSeatsCount;
            noviLokal.listaStolova = noviStolovi;

            Korisnik noviKorisnik = db.Korisnici.Where(korisnik => korisnik.hash == guid && korisnik.eMail == email && korisnik.tipKorisnika == "Menadzer" && !korisnik.validanNalog).FirstOrDefault();

            if (noviKorisnik == null)
            {
                return(RedirectToPage("/Index"));
            }
            noviKorisnik.validanNalog = true;
            noviKorisnik.mojLokal     = noviLokal;


            HttpContext.Session.SetString("email", noviKorisnik.eMail);
            await db.SaveChangesAsync();

            return(RedirectToPage("/Success"));
        }