public async Task <IHttpActionResult> PutKonobar(string id, Konobar konobar) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != konobar.id) { return(BadRequest()); } db.Entry(konobar).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!KonobarExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> PostKonobar(Konobar konobar) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Konobar.Add(konobar); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (KonobarExists(konobar.id)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = konobar.id }, konobar)); }
public void Insert(Konobar entity) { using (var db = new Entities()) { db.Konobars.Add(entity); db.SaveChanges(); } }
public ActionResult DeleteConfirmed(string id) { Konobar konobar = db.Konobar.Find(id); db.Konobar.Remove(konobar); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "KonobarId,Plata,BankovniRacun,Ime,Prezime,DatumRodjenja,Username,Password,Jmbg")] Konobar konobar) { if (ModelState.IsValid) { db.Entry(konobar).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(konobar)); }
public IHttpActionResult GetKonobar(int id) { Konobar konobar = _manager.GetById(id); if (konobar == null) { return(NotFound()); } return(Ok(konobar)); }
public async Task <IHttpActionResult> GetKonobar(string id) { Konobar konobar = await db.Konobar.FindAsync(id); if (konobar == null) { return(NotFound()); } return(Ok(konobar)); }
public ActionResult Create([Bind(Include = "KonobarId,Plata,BankovniRacun,Ime,Prezime,DatumRodjenja,Username,Password,Jmbg")] Konobar konobar) { if (ModelState.IsValid) { db.Konobar.Add(konobar); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(konobar)); }
public void DodajKonobara(KonobariEvidentirajVM vm) { Konobar konobar = new Konobar() { ImeKonobara = vm.ImeKonobara, PrezimeKonobara = vm.PrezimeKonobara, PlataKonobara = vm.PlataKonobara }; _context.Add(konobar); _context.SaveChanges(); }
public bool Update(Konobar entity) { if (_provider.GetById(entity.MBR) == null) { return(false); } else { _provider.Update(entity); return(true); } }
public void EditKonobara(KonobariEvidentirajVM vm) { var kuhar = new Konobar(); if (vm.KonobarID != 0) { kuhar = _context.Konobari.Find(vm.KonobarID); } kuhar.ImeKonobara = vm.ImeKonobara; kuhar.PrezimeKonobara = vm.PrezimeKonobara; kuhar.PlataKonobara = vm.PlataKonobara; _context.SaveChanges(); }
public bool Insert(Konobar entity) { if (_provider.GetById(entity.MBR) != null) { return(false); } entity.SIFRA = "KON" + entity.MBR; entity.Zaposleni.MBR = entity.MBR; _provider.Insert(entity); return(true); }
public IActionResult ObrisiKonobara(int KorisnikID, int KonobarID) { Konobar k = _dbContext.Konobari.Find(KonobarID); foreach (var x in _dbContext.SalaKonobari.Where(sk => sk.KonobarID == KonobarID)) { _dbContext.SalaKonobari.Remove(x); } _dbContext.Remove(k); _dbContext.SaveChanges(); return(Redirect("PrikazKonobara?KorisnikID=" + KorisnikID)); }
public async Task <IHttpActionResult> DeleteKonobar(string id) { Konobar konobar = await db.Konobar.FindAsync(id); if (konobar == null) { return(NotFound()); } db.Konobar.Remove(konobar); await db.SaveChangesAsync(); return(Ok(konobar)); }
// GET: Konobars/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Konobar konobar = db.Konobar.Find(id); if (konobar == null) { return(HttpNotFound()); } return(View(konobar)); }
private void registruj_Click(object sender, RoutedEventArgs e) { if (plata.Text.Length == 0 || racun.Text.Length == 0 || ime.Text.Length == 0 || prezime.Text.Length == 0 || username.Text.Length == 0 || password.Password.Length == 0 || !jmbgValidate(jmbg.Text) || !racunValidate()) { validacija.Opacity = 100; return; } validacija.Opacity = 0; String dan = jmbg.Text.Substring(0, 2); String mjesec = jmbg.Text.Substring(2, 2); String godina = "1" + jmbg.Text.Substring(4, 3); char p; if ((string)pol.SelectedItem == "Muški") { p = 'M'; } else { p = 'Z'; } try { Konobar obj = new Konobar(); obj.Ime = ime.Text; obj.Prezime = prezime.Text; obj.DatumRodjenja = dan + "." + mjesec + "." + godina; obj.Username = username.Text; obj.Password = password.Password; obj.Pol = p; obj.Plata = Double.Parse(plata.Text); obj.BankovniRacun = racun.Text; obj.Jmbg = jmbg.Text; obj.KonobarId = RandomString(10); konobarTableObj.InsertAsync(obj); MessageDialog dialog = new MessageDialog("Uspješno ste unijeli konobara!"); dialog.ShowAsync(); } catch (Exception ex) { MessageDialog dialog = new MessageDialog("Error: " + ex.ToString()); dialog.ShowAsync(); } //sd.dodajKonobara(ime.Text, prezime.Text, dan + "." + mjesec + "." + godina, username.Text, password.Password, p, Int32.Parse(plata.Text), racun.Text); Page adminPage = new AdminPage(sd); this.Content = adminPage; }
public void Delete(int id) { using (var db = new Entities()) { Konobar kon = db.Konobars.Where(k => k.MBR.Equals(id)).FirstOrDefault(); db.Entry(kon).State = System.Data.Entity.EntityState.Deleted; Zaposleni zap = db.Zaposlenis.Where(z => z.MBR.Equals(kon.MBR)).FirstOrDefault(); zap.Zaposleni_MBR = null; zap.Zaposleni1 = null; zap.Zaposleni2 = null; db.Entry(zap).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); } }
public IHttpActionResult PostKonobar(Konobar konobar) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (_manager.Insert(konobar)) { return(CreatedAtRoute("DefaultApi", new { id = konobar.MBR }, konobar)); } else { return(BadRequest()); } }
public void Update(Konobar entity) { using (var db = new Entities()) { Konobar toChange = db.Konobars.Where(x => x.MBR == entity.MBR).Include(x => x.Zaposleni).FirstOrDefault(); toChange.KNJIZ = entity.KNJIZ; toChange.Zaposleni.DAT = entity.Zaposleni.DAT; toChange.Zaposleni.IME = entity.Zaposleni.IME; toChange.Zaposleni.PLT = entity.Zaposleni.PLT; toChange.Zaposleni.PRZ = entity.Zaposleni.PRZ; toChange.Zaposleni.TEL = entity.Zaposleni.TEL; toChange.Zaposleni.Zaposleni_MBR = entity.Zaposleni.Zaposleni_MBR; db.Entry(toChange).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } }
public IActionResult Snimi(KonobariEvidentirajKonobareVM x) { Konobar novi = new Konobar(); if (x.KonobarID == 0) { _dbContext.Add(novi); } else { novi = _dbContext.Konobari.Find(x.KonobarID); } novi.KonobarID = x.KonobarID; novi.ImeKonobara = x.ImeKonobara; novi.PrezimeKonobara = x.PrezimeKonobara; novi.PlataKonobara = x.PlataKonobara; _dbContext.SaveChanges(); return(Redirect("PrikazKonobara?KorisnikID=" + x.KorisnikID)); }
public IHttpActionResult PutKonobar(int id, Konobar konobar) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != konobar.MBR) { return(BadRequest()); } bool ret = _manager.Update(konobar); if (ret) { return(Ok()); } else { return(BadRequest()); } }
public Konobar GetById(int id) { Konobar kon = db.Konobars.Where(k => k.MBR.Equals(id)).Include(x => x.Zaposleni).FirstOrDefault(); return(kon); }