Example #1
0
        public IHttpActionResult PutSklep(string id, Sklep sklep)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != sklep.Id)
            {
                return(BadRequest());
            }

            db.Entry(sklep).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SklepExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #2
0
        public Koszyk(Sklep sklep, Logowanie logowanie, Kasjer kasjer, List <Klient> klienci_kolejka, List <Produkt> produkty_skasowane, StaticLine note = null) : base(sklep, note)
        {
            if (logowanie != null)
            {
                this.logowanie = logowanie;
            }
            if (kasjer != null)
            {
                this.kasjer = kasjer;
            }
            if (klienci_kolejka != null)
            {
                this.klienci_kolejka = klienci_kolejka;
            }
            if (produkty_skasowane != null)
            {
                this.produkty_skasowane = produkty_skasowane;
            }

            Contents.Add(new StaticLine("WYBIERZ PRODUKT Z LISTY"));
            if (sklep.asortyment.Count == 0)
            {
                Contents.Add(new StaticLine("Brak produktów w magazynie"));
            }
            else
            {
                foreach (var p in sklep.asortyment)
                {
                    Contents.Add(new ActiveLine($" {p.nazwa} ({p.cena}zł)"));
                }
            }
            Contents.Add(new ActiveLine("Powrót"));
            Contents.Add(this.Note);
        }
Example #3
0
 public Rynek(Sklep sklep, StaticLine note = null) : base(sklep, note)
 {
     Contents.Add(new StaticLine("RYNEK"));
     Contents.Add(new StaticLine("Dostępne: (wybierz by dodać do sklepu)"));
     if (BazaDanych.Rekordy <Produkt>().Count > 0)
     {
         foreach (var p in BazaDanych.Rekordy <Produkt>())
         {
             bool interaktywna = true;
             foreach (var pa in sklep.asortyment)
             {
                 if (p.id == pa.id)
                 {
                     interaktywna = false;
                     Contents.Add(new StaticLine($" {p.nazwa} ({p.cena}zł)"));
                 }
             }
             if (interaktywna)
             {
                 Contents.Add(new ActiveLine($" {p.nazwa} ({p.cena}zł)"));
             }
         }
     }
     else
     {
         Contents.Add(new StaticLine(" Rynek jest pusty."));
     }
     Contents.Add(new ActiveLine("Zamów towar na rynek"));
     Contents.Add(new ActiveLine("Powrót"));
     Contents.Add(this.Note);
 }
Example #4
0
        public override void React(_Line line)
        {
            switch (line.Index)
            {
            case 1:
                sklep.nazwa = Console.ReadLine();
                break;

            case 2:
                sklep.adres = Console.ReadLine();
                break;

            case 3:
                if (!sklep.IsAnyNullOrEmpty())
                {
                    sklep = BazaDanych.Wstaw(sklep);
                    MWS.DisplayAdapter.Display(new Zaloguj(sklep));
                }
                break;

            case 4:
                MWS.DisplayAdapter.Display(new Sklepy());
                break;
            }
            MWS.DisplayAdapter.Display(new DodajSklep(sklep));
        }
Example #5
0
 public Statystyki(Sklep sklep, StaticLine note = null) : base(sklep, note)
 {
     Contents.Add(new StaticLine("HISTORIA"));
     Contents.Add(new ActiveLine("Powrót"));
     foreach (var k in sklep.kasjerzy)
     {
         Contents.Add(new StaticLine("========="));
         Contents.Add(new StaticLine($"KASJER: {k.logowanie.nazwa}"));
         Contents.Add(new StaticLine($" DATA ROZPOCZĘCIA: {k.data_rozpoczecia}"));
         Contents.Add(new StaticLine($" DATA ZAKOŃCZENIA: {k.data_zakonczenia}"));
         Contents.Add(new StaticLine($" CZAS PRACY: {k.data_zakonczenia-k.data_rozpoczecia}"));
         foreach (var klient in k.klienci)
         {
             Contents.Add(new StaticLine($"  KLIENT: {klient.id}"));
             Contents.Add(new StaticLine($"   DATA WEJŚCIA:    {klient.data_wejscia}"));
             Contents.Add(new StaticLine($"   DATA OBSŁUŻENIA: {klient.data_obsluzenia}"));
             Contents.Add(new StaticLine($"   CZAS OCZEKIWANIA: {klient.data_obsluzenia - klient.data_wejscia}"));
             foreach (var produkt in klient.koszyk)
             {
                 Contents.Add(new StaticLine($"    PRODUKT: {produkt.nazwa}, CENA: {produkt.cena}"));
             }
         }
     }
     Contents.Add(this.Note);
 }
Example #6
0
        public IHttpActionResult PostSklep(Sklep sklep)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Sklepy.Add(sklep);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (SklepExists(sklep.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = sklep.Id }, sklep));
        }
Example #7
0
        public ActionResult DeleteConfirmed(string id)
        {
            Sklep sklep = db.Sklepy.Find(id);

            db.Sklepy.Remove(sklep);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #8
0
        public Kasa(Sklep sklep, Logowanie logowanie, Kasjer kasjer = null, List <Klient> klienci_kolejka = null, List <Produkt> produkty_skasowane = null, StaticLine note = null) : base(sklep, note)
        {
            if (logowanie != null)
            {
                this.logowanie = logowanie;
            }
            if (kasjer != null)
            {
                this.kasjer = kasjer;
            }
            if (klienci_kolejka != null)
            {
                this.klienci_kolejka = klienci_kolejka;
            }
            if (produkty_skasowane != null)
            {
                this.produkty_skasowane = produkty_skasowane;
            }

            Contents.Add(new StaticLine("ZMIANA PRACOWNIKA " + this.logowanie.nazwa));
            Contents.Add(new StaticLine("Rozpoczęcie: " + this.kasjer.data_rozpoczecia));
            Contents.Add(new ActiveLine("Dodaj klienta do kolejki"));
            Contents.Add(new ActiveLine("Skasuj produkt"));
            Contents.Add(new ActiveLine("Finalizuj transakcję"));
            Contents.Add(new ActiveLine("Zakończ zmianę"));

            Contents.Add(new StaticLine("==SKASOWANE PRODUKTY=="));
            if (this.produkty_skasowane.Count == 0)
            {
                Contents.Add(new StaticLine("Lista jest pusta"));
            }
            else
            {
                decimal suma = 0;
                foreach (var p in this.produkty_skasowane)
                {
                    Contents.Add(new StaticLine($" {p.nazwa} ({p.cena}zł)"));
                    suma += p.cena;
                }
                Contents.Add(new StaticLine($"-DO zapłaty: {suma}zł"));
            }

            Contents.Add(new StaticLine("==KOLEJKA KLIENTÓW=="));
            if (this.klienci_kolejka.Count == 0)
            {
                Contents.Add(new StaticLine("Lista jest pusta"));
            }
            else
            {
                int licznikKlientow = 1;
                foreach (var k in this.klienci_kolejka)
                {
                    Contents.Add(new StaticLine($" Pozycja: {licznikKlientow}, wejście: {k.data_wejscia}"));
                    licznikKlientow++;
                }
            }
            Contents.Add(this.Note);
        }
Example #9
0
 void OnTriggerStay(Collider other)
 {
     if (other.tag == "Strefa")     //Update strefy po przejściu.
     {
         //print("Wszedłem do strefy " + other.gameObject.GetComponent<Strefa>().numerStrefy);
         obecnaStrefa = other.gameObject.GetComponent <Strefa>();
         mozliwySklep = obecnaStrefa.sklep;
         mozliwaLawka = obecnaStrefa.lawka;
     }
 }
        public ActionResult Create(int id)
        {
            Sklep car = _context1.Skleps.Single(a => a.SklepId == id);
            // Tworzymy nowy obiekt kontaktu
            Kontakt comm = new Kontakt();

            // Wypełniamy obiekt niezbędnymi informacjami
            comm.SklepId = id;
            return(View(comm));
        }
Example #11
0
 public ActionResult Edit([Bind(Include = "Id,LogoUrl")] Sklep sklep)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sklep).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(sklep));
 }
Example #12
0
        public IHttpActionResult GetSklep(string id)
        {
            Sklep sklep = db.Sklepy.Find(id);

            if (sklep == null)
            {
                return(NotFound());
            }

            return(Ok(sklep));
        }
Example #13
0
        public ActionResult Create([Bind(Include = "Id,LogoUrl,KategoriaId")] Sklep sklep)
        {
            if (ModelState.IsValid)
            {
                db.Sklepy.Add(sklep);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(sklep));
        }
Example #14
0
 public Zamawianie(Sklep sklep, Produkt produkt = null, StaticLine note = null) : base(sklep, note)
 {
     if (produkt != null)
     {
         this.produkt = produkt;
     }
     Contents.Add(new StaticLine("ZAMAWIANIE PRODUKTU"));
     Contents.Add(new ActiveLine("Nazwa: " + this.produkt.nazwa));
     Contents.Add(new ActiveLine($"Cena: {this.produkt.cena}zł"));
     Contents.Add(new ActiveLine("Zamów"));
     Contents.Add(new ActiveLine("Powrót"));
     Contents.Add(this.Note);
 }
Example #15
0
 public Rejestracja(Sklep sklep, Logowanie logowanie = null, StaticLine Note = null) : base(sklep, Note)
 {
     if (logowanie != null)
     {
         this.logowanie = logowanie;
     }
     Contents.Add(new StaticLine("REJESTRACJA"));
     Contents.Add(new ActiveLine("Login: "******"Hasło: " + this.logowanie.haslo));
     Contents.Add(new ActiveLine("Zarejestruj się"));
     Contents.Add(new ActiveLine("Powrót"));
     Contents.Add(this.Note);
 }
Example #16
0
 public DodajSklep(Sklep sklep = null, StaticLine Note = null) : base(Note)
 {
     if (sklep != null)
     {
         this.sklep = sklep;
     }
     Contents.Add(new StaticLine("DODAWANIE SKLEPU"));
     Contents.Add(new ActiveLine("Nazwa: " + this.sklep.nazwa));
     Contents.Add(new ActiveLine("Adres: " + this.sklep.adres));
     Contents.Add(new ActiveLine("Dodaj"));
     Contents.Add(new ActiveLine("Powrót"));
     Contents.Add(this.Note);
 }
Example #17
0
    public void kup(string nazwa, int ilosc)
    {
        Sklep   sk = new Sklep();
        Magazyn m  = new Magazyn();

        if (m.getProdukt(nazwa) == null)
        {
            Console.WriteLine("Produktu o nazwie {0} nie ma w asortymencie sklepu", nazwa);
        }
        else
        {
            sk.sprzedaj(nazwa, ilosc);
        }
    }
Example #18
0
        // GET: Sklepy/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Sklep sklep = db.Sklepy.Find(id);

            if (sklep == null)
            {
                return(HttpNotFound());
            }
            return(View(sklep));
        }
Example #19
0
        public IHttpActionResult DeleteSklep(string id)
        {
            Sklep sklep = db.Sklepy.Find(id);

            if (sklep == null)
            {
                return(NotFound());
            }

            db.Sklepy.Remove(sklep);
            db.SaveChanges();

            return(Ok(sklep));
        }
Example #20
0
 void OnTriggerExit(Collider other)
 {
     if (other.tag == "Shop")
     {
         Sklep sklep = other.gameObject.GetComponentInParent <Sklep>();
         sklep.OdejmijKlienta();
         WorldManager.instance.kasa += mozliwySklep.parent.info.neededMoney;
     }
     else if (other.tag == "Strefa")
     {
         if (other.GetComponent <Strefa>().numerStrefy == WorldManager.instance.strefy.Count - 1)
         {
             Destroy(this.gameObject);
         }
     }
 }
Example #21
0
        private static void Menu()
        {
            Sklep sklep = new Sklep();

            var types = Assembly
                        .GetExecutingAssembly()
                        .GetTypes()
                        .Where(x => x.IsInterface == false && x.Namespace.StartsWith("SklepOdziezowy.Domena.Towar")).ToList();

            foreach (var type in types)
            {
                Console.WriteLine(type.Name);
            }

            Console.WriteLine("Napisz co chcesz");

            string result = Console.ReadLine();

            result = result.Trim().ToUpper();
            switch (result)
            {
            case "SPODNIE":
            {
                WyswietlTowar(sklep.Towar.Where(x => x.GetType() == typeof(Spodnie)).ToList());
                break;
            }

            case "SUKIENKA":
            {
                WyswietlTowar(sklep.Towar.Where(x => x.GetType() == typeof(Sukienka)).ToList());

                break;
            }

            case "BUTY":
            {
                WyswietlTowar(sklep.Towar.Where(x => x.GetType() == typeof(Buty)).ToList());
                break;
            }

            case "KURTKA":
            {
                WyswietlTowar(sklep.Towar.Where(x => x.GetType() == typeof(Kurtka)).ToList());
                break;
            }
            }
        }
Example #22
0
 public ActionResult Create([Bind(Include = "Id,LogoUrl,KategoriaId")] Sklep sklep)
 {
     if (ModelState.IsValid && ServerTools.TempFolderContains(sklep.LogoUrl))
     {
         string sourcePath      = Path.Combine(ServerTools.TempFolderPath, sklep.LogoUrl);
         string destinationPath = Path.Combine(ServerTools.MediaFolderPath("Logos"), sklep.LogoUrl);
         System.IO.File.Move(sourcePath, destinationPath);
         //todo server side image resize
         sklep.LogoUrl = ServerTools.RelativePath(destinationPath);
         db.Sklepy.Add(sklep);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     //todo chech if logo uploaded
     ViewBag.KategoriaId = new SelectList(db.Kategorie, "Id", "Id");
     return(View(sklep));
 }
Example #23
0
        public Zaloguj(Sklep sklep, Logowanie logowanie = null, StaticLine Note = null) : base(sklep, Note)
        {
            if (logowanie != null)
            {
                this.logowanie = logowanie;
            }

            Contents.Add(new StaticLine("WYBRANY SKLEP: " + this.sklep.nazwa.ToUpper()));
            Contents.Add(new ActiveLine(" Login: "******" Hasło: " + this.logowanie.haslo));
            Contents.Add(new ActiveLine(" Zaloguj się i rozpocznij zmianę"));
            Contents.Add(new ActiveLine(" Zarejestruj kasjera"));
            Contents.Add(new ActiveLine("Statystyki sklepu"));
            Contents.Add(new ActiveLine("Asortyment sklepu"));
            Contents.Add(new ActiveLine("Powrót"));
            Contents.Add(this.Note);
        }
Example #24
0
 public Asortyment(Sklep sklep, StaticLine note = null) : base(sklep, note)
 {
     Contents.Add(new StaticLine("ASORTYMENT SKLEPU"));
     Contents.Add(new StaticLine("Dostępne: (wybierz by usunąć)"));
     if (sklep.asortyment.Count > 0)
     {
         foreach (var p in sklep.asortyment)
         {
             Contents.Add(new ActiveLine($" {p.nazwa} ({p.cena}zł)"));
         }
     }
     else
     {
         Contents.Add(new StaticLine(" Magazyn jest pusty."));
     }
     Contents.Add(new ActiveLine("Rynek produktów"));
     Contents.Add(new ActiveLine("Powrót"));
     Contents.Add(this.Note);
 }
        public void TestTowary()
        {
            Sklep sklep = new Sklep();

            sklep.GetTowary();

            Sklep mango = new Mango();

            mango.GetTowary();
            Sklep grycan = new Grycan();

            grycan.GetTowary();
            Sklep hAndM = new HAndM();

            hAndM.GetTowary();

            Sklep empik = new Empik();

            empik.GetTowary();
        }
Example #26
0
 public static T Wstaw <T>(T obiekt, Encja obiekt2 = null) where T : Encja
 {
     if (typeof(T) == typeof(Sklep))
     {
         if (obiekt2 is null)
         {
             return(Sklep.Wstaw(obiekt as Sklep) as T);
         }
         else if (obiekt2 is Produkt)
         {
             Sklep_Produkt.Wstaw(obiekt as Sklep, obiekt2 as Produkt);
         }
     }
     else if (typeof(T) == typeof(Kasjer))
     {
         return(Kasjer.Wstaw(obiekt as Kasjer) as T);
     }
     else if (typeof(T) == typeof(Klient))
     {
         if (obiekt2 is null)
         {
             return(Klient.Wstaw(obiekt as Klient) as T);
         }
         else if (obiekt2 is Produkt)
         {
             Klient_Produkt.Wstaw(obiekt as Klient, obiekt2 as Produkt);
         }
     }
     else if (typeof(T) == typeof(Logowanie))
     {
         return(Logowanie.Wstaw(obiekt as Logowanie) as T);
     }
     else if (typeof(T) == typeof(Produkt))
     {
         return(Produkt.Wstaw(obiekt as Produkt) as T);
     }
     return(null);
 }
Example #27
0
 public static void Usun <T>(T obiekt, Encja obiekt2 = null) where T : Encja
 {
     if (typeof(T) == typeof(Sklep))
     {
         if (obiekt2 is null)
         {
             Sklep.Usun(obiekt as Sklep);
         }
         else if (obiekt2 is Produkt)
         {
             Sklep_Produkt.Usun(obiekt as Sklep, obiekt2 as Produkt);
         }
     }
     else if (typeof(T) == typeof(Kasjer))
     {
         Kasjer.Usun(obiekt as Kasjer);
     }
     else if (typeof(T) == typeof(Klient))
     {
         if (obiekt2 is null)
         {
             Klient.Usun(obiekt as Klient);
         }
         else if (obiekt2 is Produkt)
         {
             Klient_Produkt.Wstaw(obiekt as Klient, obiekt2 as Produkt);
         }
     }
     else if (typeof(T) == typeof(Logowanie))
     {
         Logowanie.Usun(obiekt as Logowanie);
     }
     else if (typeof(T) == typeof(Produkt))
     {
         Produkt.Usun(obiekt as Produkt);
     }
 }
Example #28
0
 public static T ZnajdzRekord <T>(int id) where T : Encja
 {
     if (typeof(T) == typeof(Sklep))
     {
         return(Sklep.ZnajdzRekord(id) as T);
     }
     else if (typeof(T) == typeof(Kasjer))
     {
         return(Kasjer.ZnajdzRekord(id) as T);
     }
     else if (typeof(T) == typeof(Klient))
     {
         return(Klient.ZnajdzRekord(id) as T);
     }
     else if (typeof(T) == typeof(Logowanie))
     {
         return(Logowanie.ZnajdzRekord(id) as T);
     }
     else if (typeof(T) == typeof(Produkt))
     {
         return(Produkt.ZnajdzRekord(id) as T);
     }
     throw new Exception("Nie sprecyzowano typu");
 }
Example #29
0
 public static void Zmien <T>(T obiektPrzed, T obiektPo = null) where T : Encja
 {
     obiektPo.id = obiektPrzed.id;
     if (typeof(T) == typeof(Sklep))
     {
         Sklep.Zmien(obiektPo as Sklep);
     }
     else if (typeof(T) == typeof(Kasjer))
     {
         Kasjer.Zmien(obiektPo as Kasjer);
     }
     else if (typeof(T) == typeof(Klient))
     {
         Klient.Zmien(obiektPo as Klient);
     }
     else if (typeof(T) == typeof(Logowanie))
     {
         Logowanie.Zmien(obiektPo as Logowanie);
     }
     else if (typeof(T) == typeof(Produkt))
     {
         Produkt.Zmien(obiektPo as Produkt);
     }
 }
Example #30
0
        public ActionResult Save(Sklep sklep)
        {
            if (!ModelState.IsValid)
            {
                var viewModel = new SklepViewModel
                {
                    Sklep         = sklep,
                    FormatSklepus = _context.FormatSklepus.ToList()
                };
                return(View("SklepFormularz", viewModel));
            }

            if (sklep.SklepId == 0)
            {
                sklep.DataUtworzeniaSklepu = DateTime.Now;
                _context.Skleps.Add(sklep);
            }
            else
            {
                var sklepInDb = _context.Skleps.Single(s => s.SklepId == sklep.SklepId);
                sklepInDb.Nazwa          = sklep.Nazwa;
                sklepInDb.FormatSklepuId = sklep.FormatSklepuId;
                sklepInDb.Nip            = sklep.Nip;
                sklepInDb.Miejscowosc    = sklep.Miejscowosc;
                sklepInDb.Ulica          = sklep.Ulica;
                sklepInDb.NrLokalu       = sklep.NrLokalu;
                sklepInDb.Kod            = sklep.Kod;
                sklepInDb.Uwagi          = sklep.Uwagi;
                sklepInDb.CzyParking     = sklep.CzyParking;
                sklepInDb.CzySieciowy    = sklep.CzySieciowy;
                sklepInDb.Powierzchnia   = sklep.Powierzchnia;
                sklepInDb.TypSklepu      = sklep.TypSklepu;
            }
            _context.SaveChanges();
            return(RedirectToAction("Index", "Sklep"));
        }