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)); }
public Rezervacija(int brojRezervacije, NacinPlacanja placanje, StatusRezervacije status) { this.brojRezervacije = brojRezervacije; this.placanje = placanje; this.status = status; }
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); }
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); } }
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)); }
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); }
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(); } }
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; }
public IHttpActionResult GetNacinPlacanja(int id) { NacinPlacanja nacinPlacanja = db.NacinPlacanja.Find(id); if (nacinPlacanja == null) { return(NotFound()); } return(Ok(nacinPlacanja)); }
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)); }
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)); }
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)); }
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)); }
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); } }
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."); } }
public void SacuvajNacinPlacanja(NacinPlacanja nacinPlacanja) { Channel.SacuvajNacinPlacanja(nacinPlacanja); }
public void ZakljuciRacun(NacinPlacanja nacin_pl, Racun_kljucno racun_Kljucno, R1_racun r1_Racun) { throw new NotImplementedException(); }
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; }