Exemple #1
0
        public async Task <Guid> CreateNarudzbenicaAsync(CancellationToken ct, string BrojNarudzbenice, Guid idKupac, Guid idZaposleni, Guid idStatusDostave, string nacinPlacanja, DateTime datumPrijema, Guid idVozilo)
        {
            Guid ID = Guid.NewGuid();
            var  newNarudzbenica = _dbContext.Narudzbenica.Add(
                new Entities.Narudzbenica
            {
                NarudzbenicaID   = ID,
                BrojNarudzbenice = BrojNarudzbenice,
                datumPrijema     = datumPrijema,
                KupacID          = idKupac,
                NacinPlacanja    = nacinPlacanja,
                StatusDostaveID  = idStatusDostave,
                VoziloID         = idVozilo,
                ZaposleniId      = idZaposleni
            }
                );

            var created = await _dbContext.SaveChangesAsync(ct);

            if (created < 1)
            {
                throw new InvalidOperationException("Can't created new resource");
            }

            return(ID);
        }
Exemple #2
0
        public async Task <Guid> CreateTipVozilaAsync(CancellationToken ct, string vrstaVozila)
        {
            Guid ID           = Guid.NewGuid();
            var  newTipVozila = _dbContext.TipVozila.Add(
                new Entities.TipVozila
            {
                TipVozilaID = ID,
                vrstaVozila = vrstaVozila
            }
                );

            var created = await _dbContext.SaveChangesAsync(ct);

            if (created < 1)
            {
                throw new InvalidOperationException("Can't created new resource");
            }

            return(ID);
        }
        public async Task <Guid> CreateStatusDostaveAsync(CancellationToken ct, string nazivStatusaDostave)
        {
            Guid ID        = Guid.NewGuid();
            var  newAdresa = _dbContext.StatusDostave.Add(
                new Entities.StatusDostave
            {
                StatusDostaveID = ID,
                NazivStatusa    = nazivStatusaDostave
            }
                );

            var created = await _dbContext.SaveChangesAsync(ct);

            if (created < 1)
            {
                throw new InvalidOperationException("Can't created new resource");
            }

            return(ID);
        }
        public async Task <Guid> CreateEkstraDodaciAsync(CancellationToken ct, Guid IdDodatak, Guid IdDetaljiNardzbenice)
        {
            Guid ID = Guid.NewGuid();
            var  newEkstraDodatak = _dbContext.EkstraDodaci.Add(
                new Entities.EkstraDodaci
            {
                Ekstra_dodaciID       = ID,
                DetaljiNarudzbeniceID = IdDetaljiNardzbenice,
                DodatakID             = IdDodatak
            }
                );

            var created = await _dbContext.SaveChangesAsync(ct);

            if (created < 1)
            {
                throw new InvalidOperationException("Can't created new ekstraDodatak");
            }

            return(ID);
        }
Exemple #5
0
        public async Task <Guid> CreateDodatakAsync(CancellationToken ct, string nazivDodatka, int cena)
        {
            Guid ID         = Guid.NewGuid();
            var  newDodatak = _dbContext.Dodaci.Add(
                new Entities.Dodatak
            {
                DodatakID     = ID,
                Naziv_dodatka = nazivDodatka,
                Cena          = cena,
            }
                );

            var created = await _dbContext.SaveChangesAsync(ct);

            if (created < 1)
            {
                throw new InvalidOperationException("Can't created new resource");
            }

            return(ID);
        }
Exemple #6
0
        public async Task <Guid> CreateAdresaAsync(CancellationToken ct, string ulica, int broj, string grad)
        {
            Guid ID        = Guid.NewGuid();
            var  newAdresa = _dbContext.Adrese.Add(
                new Entities.Adresa
            {
                AdresaID = ID,
                Broj     = broj,
                Grad     = grad,
                Ulica    = ulica
            }
                );

            var created = await _dbContext.SaveChangesAsync(ct);

            if (created < 1)
            {
                throw new InvalidOperationException("Can't created new resource");
            }

            return(ID);
        }
Exemple #7
0
        public async Task <Guid> CreatePiacaAsync(CancellationToken ct, string nazivPice, string kratak_opis, int cena)
        {
            Guid ID      = Guid.NewGuid();
            var  newPica = _dbContext.Pice.Add(
                new Entities.Pica
            {
                PicaID      = ID,
                NazivPice   = nazivPice,
                Kratak_opis = kratak_opis,
                Cena        = cena
            }
                );

            var created = await _dbContext.SaveChangesAsync(ct);

            if (created < 1)
            {
                throw new InvalidOperationException("Can't created new resource");
            }

            return(ID);
        }
Exemple #8
0
        public async Task <Guid> CreateVoziloAsync(CancellationToken ct, Guid tipVozila, string evidencioniBr, string markaVozila, string detaljiVozila)
        {
            Guid ID        = Guid.NewGuid();
            var  newVozilo = _dbContext.Vozila.Add(
                new Entities.Vozilo
            {
                VoziloID      = ID,
                EvidencioniBr = evidencioniBr,
                MarkaVozila   = markaVozila,
                DetaljiVozila = detaljiVozila,
                TipVozilaID   = tipVozila
            }
                );

            var created = await _dbContext.SaveChangesAsync(ct);

            if (created < 1)
            {
                throw new InvalidOperationException("Can't created new resource");
            }

            return(ID);
        }
Exemple #9
0
        public async Task <Guid> CreateZaposleniAsync(CancellationToken ct, string ime, string prezime, Guid idAdresa, string brTelefona)
        {
            Guid ID        = Guid.NewGuid();
            var  newAdresa = _dbContext.Zaposleni.Add(
                new Entities.Zaposleni
            {
                ZaposleniId  = ID,
                Ime          = ime,
                Prezime      = prezime,
                BrojTelefona = brTelefona,
                AdresaID     = idAdresa
            }
                );

            var created = await _dbContext.SaveChangesAsync(ct);

            if (created < 1)
            {
                throw new InvalidOperationException("Can't created new resource");
            }

            return(ID);
        }
Exemple #10
0
        public async Task <Guid> CreateKupacAsync(CancellationToken ct, string ime, string prezime, string telefon, Guid idAdresa)
        {
            Guid ID        = Guid.NewGuid();
            var  newAdresa = _dbContext.Kupci.Add(
                new Entities.Kupac
            {
                KupacID  = ID,
                Ime      = ime,
                Prezime  = prezime,
                Telefon  = telefon,
                AdresaID = idAdresa
            }
                );

            var created = await _dbContext.SaveChangesAsync(ct);

            if (created < 1)
            {
                throw new InvalidOperationException("Can't created new resource");
            }

            return(ID);
        }