Ejemplo n.º 1
0
        public IHttpActionResult PutNacinPlacanja(int id, NacinPlacanja nacinPlacanja)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != nacinPlacanja.NacinPlacanjaID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 2
0
        public Rezervacija(int brojRezervacije, NacinPlacanja placanje, StatusRezervacije status)

        {
            this.brojRezervacije = brojRezervacije;
            this.placanje        = placanje;
            this.status          = status;
        }
Ejemplo n.º 3
0
        public HttpResponseMessage SacuvajNacinPlacanja(HttpRequestMessage request, [FromBody] NacinPlacanja nacinPlacanja)
        {
            HttpResponseMessage response = null;

            try
            {
                using (SystemClient proxy = new SystemClient())
                {
                    proxy.Open();
                    proxy.SacuvajNacinPlacanja(nacinPlacanja);
                    response = request.CreateResponse(HttpStatusCode.OK);
                    proxy.Close();
                }
            }
            catch (FaultException ex)
            {
                response = request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message);
            }
            catch (Exception ex)
            {
                response = request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message);
            }

            return(response);
        }
Ejemplo n.º 4
0
        public void SacuvajNacinPlacanja(NacinPlacanja nacinPlacanja)
        {
            try
            {
                using (BHaoDataContext context = new BHaoDataContext())
                {
                    IDataRepository <NacinPlacanja> repo = new DataRepositoryBase <NacinPlacanja>(context);

                    if (repo.GetAll().Where(x => x.Opis == nacinPlacanja.Opis && x.isDeleted == false).FirstOrDefault() != null)
                    {
                        throw new Exception(String.Format("Način plaćanja '{0}' već postoji u bazi.", nacinPlacanja.Opis.ToLower()));
                    }

                    if (nacinPlacanja.Id != 0)
                    {
                        NacinPlacanja np = repo.Get(nacinPlacanja.Id);
                        np.Opis      = nacinPlacanja.Opis;
                        np.isDeleted = nacinPlacanja.isDeleted;

                        repo.Update(np);
                    }
                    else
                    {
                        repo.Insert(nacinPlacanja);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
Ejemplo n.º 5
0
 public Kupac(string ime, int dzeparac, NacinPlacanja nacinPlacanja)
 {
     Korpa         = new List <Proizvod>();
     Ime           = ime;
     Dzeparac      = dzeparac;
     NacinPlacanja = nacinPlacanja;
 }
        public async Task <IActionResult> Edit(int id, [Bind("NacinPlacanjaId")] NacinPlacanja nacinPlacanja)
        {
            if (id != nacinPlacanja.NacinPlacanjaId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(nacinPlacanja);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!NacinPlacanjaExists(nacinPlacanja.NacinPlacanjaId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(nacinPlacanja));
        }
Ejemplo n.º 7
0
        public Dictionary <NacinPlacanja, decimal> GetIznosForAllNacinPlacanja()
        {
            try
            {
                Dictionary <NacinPlacanja, decimal> temp = new Dictionary <NacinPlacanja, decimal>();

                string[] npArray = Enum.GetNames(typeof(NacinPlacanja));
                foreach (string np in npArray)
                {
                    NacinPlacanja currentNacinPlacanja = (NacinPlacanja)Enum.Parse(typeof(NacinPlacanja), np);
                    decimal       iznos = 0;
                    foreach (Racun racun in this.Racuni)
                    {
                        if (racun.NacinPlacanja == currentNacinPlacanja)
                        {
                            iznos += racun.Iznos;
                        }
                    }

                    temp.Add(currentNacinPlacanja, iznos);
                }

                return(temp);
            }
            catch (System.Exception ex)
            {
            }
            return(null);
        }
Ejemplo n.º 8
0
 public static void ZakljuciRacun(NacinPlacanja np)
 {
     using (MySqlConnection mysql = new MySqlConnection(Login.constring)) {
         mysql.Open();
         string       query        = "UPDATE racuni_zaglavlje" + godina_ref + " SET aktivan=0 WHERE id_racun=" + (Count());
         MySqlCommand mySqlCommand = new MySqlCommand(query, mysql);
         mySqlCommand.ExecuteNonQuery();
     }
 }
Ejemplo n.º 9
0
        public Narudzba(int _brojNarudzbe, DateTime _vrijemeNarudzbe, NacinPlacanja _tipPlacanja, Klijent _klijent)
        {
            this.BrojNarudzbe    = _brojNarudzbe;
            this.VrijemeNarudzbe = _vrijemeNarudzbe;
            this.TipPlacanja     = _tipPlacanja;
            this.Kupac           = _klijent;
            ObservableCollection <Artikal> _listaArtikala = new ObservableCollection <Artikal>();

            this.listaArtikala = _listaArtikala;
        }
Ejemplo n.º 10
0
        public IHttpActionResult GetNacinPlacanja(int id)
        {
            NacinPlacanja nacinPlacanja = db.NacinPlacanja.Find(id);

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

            return(Ok(nacinPlacanja));
        }
Ejemplo n.º 11
0
        public decimal GetIznosForNacinPlacanja(NacinPlacanja nacinPlacanja)
        {
            Dictionary <NacinPlacanja, decimal> temp = GetIznosForAllNacinPlacanja();

            if (temp == null)
            {
                return(Decimal.Zero);
            }

            return(temp[nacinPlacanja]);
        }
        public async Task <IActionResult> Create([Bind("NacinPlacanjaId")] NacinPlacanja nacinPlacanja)
        {
            if (ModelState.IsValid)
            {
                _context.Add(nacinPlacanja);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(nacinPlacanja));
        }
Ejemplo n.º 13
0
        public IHttpActionResult PostNacinPlacanja(NacinPlacanja nacinPlacanja)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.NacinPlacanja.Add(nacinPlacanja);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = nacinPlacanja.NacinPlacanjaID }, nacinPlacanja));
        }
Ejemplo n.º 14
0
        public IHttpActionResult DeleteNacinPlacanja(int id)
        {
            NacinPlacanja nacinPlacanja = db.NacinPlacanja.Find(id);

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

            db.NacinPlacanja.Remove(nacinPlacanja);
            db.SaveChanges();

            return(Ok(nacinPlacanja));
        }
Ejemplo n.º 15
0
        public async Task <NarudzbaResponse> Insert(int korisnikID, NarudzbaInsertRequest request)
        {
            var nacinPlacanja = new NacinPlacanja()
            {
                Naziv = "Pouzećem"
            };

            _context.NaciniPlacanja.Add(nacinPlacanja);
            await _context.SaveChangesAsync();

            var entity = _mapper.Map <Narudzba>(request);

            entity.KorisnikID      = korisnikID;
            entity.NacinPlacanjaID = nacinPlacanja.ID;

            _context.Set <Narudzba>().Add(entity);
            await _context.SaveChangesAsync();

            foreach (var detalj in request.NarudzbaDetalji)
            {
                detalj.NarudzbaID = entity.ID;
            }
            var detalji = _mapper.Map <List <NarudzbaDetalji> >(request.NarudzbaDetalji);

            _context.NarudzbaDetalji.AddRange(detalji);
            await _context.SaveChangesAsync();

            double suma    = 0;
            var    message = "Poštovana/i, " + _context.Users.Find(entity.KorisnikID).Ime + " " + _context.Users.Find(entity.KorisnikID).Prezime +
                             ", uspješno ste naručili vaša jela: \n";

            message += "\n";
            foreach (var x in detalji)
            {
                message += _context.Jela.Find(x.JeloID).Naziv + "\t" + " - " + x.Cijena + " KM" + "(" + x.Kolicina + " kom), \n";
                suma    += x.Kolicina * x.Cijena;
            }

            message += "Ukupna cijena narudžbe: " + suma + " KM \n";
            message += "Lijep pozdrav!";


            await _emailSender.SendEmailAsync(new string[] { entity.Korisnik.Email }, "Potvrda narudžbe", message);

            return(_mapper.Map <NarudzbaResponse>(entity));
        }
Ejemplo n.º 16
0
        public void ObrisiNacinPlacanja(int id)
        {
            try
            {
                using (BHaoDataContext context = new BHaoDataContext())
                {
                    IDataRepository <NacinPlacanja> repo = new DataRepositoryBase <NacinPlacanja>(context);

                    if (id > 0)
                    {
                        NacinPlacanja np = repo.Get(id);
                        np.isDeleted = true;
                        repo.Update(np);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
Ejemplo n.º 17
0
        public void Kupi(ProdajnoMesto mesto, int proizvod, NacinPlacanja nacinPlacanja)
        {
            Proizvod trazenProizvod = mesto.ListaProizvoda.FirstOrDefault(p => p.Id == proizvod);

            if (trazenProizvod != null && trazenProizvod.Cena <= Dzeparac)
            {
                string message = $"Kupljen proizvod: Proizvod ID: [{proizvod}], Naziv mesta: [{mesto.Naziv}], Ime zaposlenog prodavca: [{mesto.ListaZaposlenih.FirstOrDefault(r => r.Zaduzenje == "prodavac").Ime}], Nacin placanja: [{nacinPlacanja.ToString()}], Ime kupca: [{Ime}]";

                Korpa.Add(trazenProizvod);
                Dzeparac -= trazenProizvod.Cena;
                mesto.ListaProizvoda.Remove(trazenProizvod);
                Log      logger = new Log();
                DateTime time   = DateTime.Now;
                logger.LogAction(time, "KupovinaLog", message);
            }
            else if (trazenProizvod == null)
            {
                Console.WriteLine("Proizvod trenutno nije dostupan u prodavnici.");
            }
            else
            {
                Console.WriteLine("Nemate dovoljno sredstava.");
            }
        }
Ejemplo n.º 18
0
 public void SacuvajNacinPlacanja(NacinPlacanja nacinPlacanja)
 {
     Channel.SacuvajNacinPlacanja(nacinPlacanja);
 }
Ejemplo n.º 19
0
 public void ZakljuciRacun(NacinPlacanja nacin_pl, Racun_kljucno racun_Kljucno, R1_racun r1_Racun)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 20
0
 public Rezervacija(int brO, int brD, DateTime dD, DateTime dO, Boolean par, Boolean ljubimac, Boolean dodatniKr, NacinPlacanja np)
 {
     this.brojOdraslih  = brO;
     this.brojDjece     = brD;
     this.datumDolaska  = dD;
     this.datumOdlaska  = dO;
     this.parking       = par;
     this.ljubimac      = ljubimac;
     this.dodatniKrevet = dodatniKr;
     this.nacinPlacanja = np;
 }