public ActionResult Delete(Uplatnica uplatnica) { int id = uplatnica.Racun.Id; UplatnicaRepo.Delete(uplatnica.Id); return(RedirectToAction("Index", new { id })); }
public bool Update(Uplatnica uplatnica) { try { using (SqlConnection connection = new SqlConnection(ConnectionString)) { using (SqlCommand cmd = connection.CreateCommand()) { cmd.CommandText = "UPDATE uplatnica set iznos_uplate=@iznos,datum_prometa=@datum,svrha_uplate=@svrha,uplatilac=@uplatilac where id_uplatnice=@id"; cmd.Parameters.AddWithValue("@iznos", uplatnica.IznosUplate); cmd.Parameters.AddWithValue("@datum", uplatnica.DatumPrometa); cmd.Parameters.AddWithValue("@svrha", uplatnica.SvrhaUplate); cmd.Parameters.AddWithValue("@uplatilac", uplatnica.Uplatilac); cmd.Parameters.AddWithValue("@id", uplatnica.Id); connection.Open(); var affectedRows = cmd.ExecuteNonQuery(); if (affectedRows == 1) { return(true); } } } } catch (Exception e) { Console.WriteLine(e.StackTrace); } return(false); }
public ActionResult Index(Uplatnica uplatnica, int id) { double suma = 0; var racun = racunRepo.GetById(id); ViewBag.BrojRacuna = racun.BrojRacuna; ViewBag.NosilacRacuna = racun.NosilacRacuna; ViewBag.RacunId = racun.RacunId; ViewBag.StatusRacuna = racun.Aktivan.ToString(); var upl = uplatnicaRepo.GetAll(id); foreach (var up in upl) { suma += up.IznosUplate; } ViewBag.Uplatnice = upl; ViewBag.Suma = suma; if (ModelState.IsValid) { uplatnicaRepo.Create(uplatnica, id); return(RedirectToAction("Index", new { id = uplatnica.RacunId })); } return(View(uplatnica)); }
public ActionResult DeleteConfirmed(int id) { Uplatnica uplatnica = db.Uplatnice.Find(id); db.Uplatnice.Remove(uplatnica); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "UplatnicaId,RacunId,Iznos,DatumPrometa,SvrhaUplate,Uplatilac,Hitno")] Uplatnica uplatnica) { if (ModelState.IsValid) { db.Entry(uplatnica).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.RacunId = new SelectList(db.Racuni, "RacunId", "NosilacRacuna", uplatnica.RacunId); return(View(uplatnica)); }
public ActionResult Index(int id) { RacunUplatniceViewModel ruvm = new RacunUplatniceViewModel(); ruvm.Racun = RacunRepo.GetById(id); Uplatnica uplatnica = new Uplatnica(); uplatnica.Racun = ruvm.Racun; ruvm.Uplatnica = uplatnica; ruvm.UplatniceRacuna = UplatnicaRepo.GetByRacunId(id); return(View(ruvm)); }
public IHttpActionResult Post(UplatnicaModel model) { if (model != null) { using (var context = new xws_firmaEntities()) { Uplatnica uplatnica = new Uplatnica(); uplatnica.DuznikNalogodavac = model.DuznikNalogodavac; uplatnica.SvrhaPlacanja = model.SvrhaPlacanja; uplatnica.PoverilacPrimalac = model.PoverilacPrimalac; uplatnica.MestoDatumPrijema = model.MestoDatumPrijema; uplatnica.SifraPlacanja = model.SifraPlacanja; uplatnica.Cena = model.Cena; uplatnica.RacunDuznikaNalogodavca = model.RacunDuznikaNalogodavca; uplatnica.Model = model.Model; uplatnica.PozivNaBrojZaduzenja = model.PozivNaBrojZaduzenja; uplatnica.RecunPoveriocaPrimaoca = model.RecunPoveriocaPrimaoca; uplatnica.Model2 = model.Model2; uplatnica.RacunNaBrojOdobrenje = model.RacunNaBrojOdobrenje; uplatnica.DatumValute = model.DatumValute; uplatnica.Hitno = model.Checkbox; context.Uplatnicas.Add(uplatnica); context.SaveChanges(); } BankApiService.ServiceBankClient bs = new BankApiService.ServiceBankClient(); BankApiService.UplatnicaModel bankUplatnica = new BankApiService.UplatnicaModel(); bankUplatnica.DuznikNalogodavac = model.DuznikNalogodavac; bankUplatnica.SvrhaPlacanja = model.SvrhaPlacanja; bankUplatnica.PoverilacPrimalac = model.PoverilacPrimalac; bankUplatnica.MestoDatumPrijema = model.MestoDatumPrijema; bankUplatnica.SifraPlacanja = model.SifraPlacanja; bankUplatnica.Cena = model.Cena; bankUplatnica.RacunDuznikaNalogodavca = model.RacunDuznikaNalogodavca; bankUplatnica.Model = model.Model; bankUplatnica.PozivNaBrojZaduzenja = model.PozivNaBrojZaduzenja; bankUplatnica.RecunPoveriocaPrimaoca = model.RecunPoveriocaPrimaoca; bankUplatnica.Model2 = model.Model2; bankUplatnica.RacunNaBrojOdobrenje = model.RacunNaBrojOdobrenje; bankUplatnica.DatumValute = model.DatumValute; bankUplatnica.Checkbox = model.Checkbox; bool isOk = bs.AddUplatnica(bankUplatnica); if (isOk) { return(Ok()); } } return(BadRequest()); }
// GET: Uplatnica/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Uplatnica uplatnica = db.Uplatnice.Find(id); if (uplatnica == null) { return(HttpNotFound()); } return(View(uplatnica)); }
public ActionResult Update(Uplatnica uplatnica) { int id = uplatnica.Racun.Id; if (ModelState.IsValid) { bool updated = UplatnicaRepo.Update(uplatnica); if (updated) { return(RedirectToAction("Index", new { id })); } } return(View(uplatnica)); }
// GET: Uplatnica/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Uplatnica uplatnica = db.Uplatnice.Find(id); if (uplatnica == null) { return(HttpNotFound()); } ViewBag.RacunId = new SelectList(db.Racuni, "RacunId", "NosilacRacuna", uplatnica.RacunId); return(View(uplatnica)); }
public ActionResult Edit(Uplatnica uplatnica) { var racuni = racunRepo.GetAll(); var racun = racunRepo.GetById(uplatnica.RacunId); ViewBag.Racuni = new SelectList(racuni, "RacunId", "BrojRacuna", uplatnica.RacunId); ViewBag.BrojRacuna = racun.BrojRacuna; ViewBag.NosilacRacuna = racun.NosilacRacuna; if (ModelState.IsValid) { uplatnicaRepo.Edit(uplatnica); return(RedirectToAction("Index", new { id = uplatnica.RacunId })); } return(View(uplatnica)); }
public void TestRacuna() { UplatnicaRepo uRepo = new UplatnicaRepo(); RacunRepo rRepo = new RacunRepo(); Racun racun = new Racun(); racun.BrojRacuna = "TEST BROJ RACUNA"; racun.NosilacRacuna = "TEST NOSILAC RACUNA"; int idRac = rRepo.Create(racun); Assert.IsTrue(idRac > 0, "Kreiranje racuna"); racun.Id = idRac; Assert.IsTrue(rRepo.GetSum(idRac) == 0, "Prvi test ukupnog stanja"); Uplatnica uplatnica = new Uplatnica(); uplatnica.Racun = racun; uplatnica.IznosUplate = 100; uplatnica.SvrhaUplate = "TEST SVRHE"; uplatnica.Uplatilac = "TEST UPLATILAC"; int idUpl1 = uRepo.Create(uplatnica); Assert.IsTrue(idUpl1 > 0, "Kreiranje uplatnice 1"); Assert.IsTrue(rRepo.GetSum(idRac) == 100, "Drugi test ukupnog stanja"); Uplatnica uplatnica2 = new Uplatnica(); uplatnica2.Racun = racun; uplatnica2.IznosUplate = -100; uplatnica2.SvrhaUplate = "TEST SVRHE"; uplatnica2.Uplatilac = "TEST UPLATILAC"; int idUpl2 = uRepo.Create(uplatnica2); Assert.IsTrue(idUpl2 > 0, "Kreiranje uplatnice 2"); Assert.IsTrue(rRepo.GetSum(idRac) == 0, "Treci test ukupnog stanja"); bool deleteRacun = rRepo.Delete(idRac); Assert.IsTrue(deleteRacun, "Brisanje Racuna"); }
public IEnumerable <Uplatnica> GetByRacunId(int id) { List <Uplatnica> uplatniceRacuna = new List <Uplatnica>(); try { using (SqlConnection connection = new SqlConnection(ConnectionString)) { using (SqlCommand cmd = connection.CreateCommand()) { cmd.CommandText = "select * from racun,uplatnica where racun.id_racuna=uplatnica.id_racuna and racun.id_racuna=@id"; cmd.Parameters.AddWithValue("@id", id); SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = cmd; DataTable dt = new DataTable(); adapter.Fill(dt); foreach (DataRow dr in dt.Rows) { Uplatnica uplatnica = new Uplatnica(); uplatnica.Id = (int)dr["id_uplatnice"]; uplatnica.IznosUplate = (decimal)dr["iznos_uplate"]; uplatnica.DatumPrometa = (DateTime)dr["datum_prometa"]; uplatnica.SvrhaUplate = (string)dr["svrha_uplate"]; uplatnica.Uplatilac = (string)dr["uplatilac"]; uplatnica.Hitno = Convert.ToByte(dr["hitno"]) == 0 ? false : true; Racun racun = rRepo.GetById((int)dr["id_racuna"]); uplatnica.Racun = racun; uplatniceRacuna.Add(uplatnica); } } } } catch (Exception e) { Console.WriteLine(e.StackTrace); } return(uplatniceRacuna); }
public Uplatnica GetById(int id) { try { using (SqlConnection connection = new SqlConnection(ConnectionString)) { using (SqlCommand cmd = connection.CreateCommand()) { cmd.CommandText = "select * from uplatnica where id_uplatnice=@id "; cmd.Parameters.AddWithValue("@id", id); SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = cmd; DataTable dt = new DataTable(); adapter.Fill(dt); if (dt.Rows.Count == 1) { Racun racun = rRepo.GetById((int)dt.Rows[0]["id_racuna"]); Uplatnica uplatnica = new Uplatnica(); uplatnica.Racun = racun; uplatnica.Id = (int)dt.Rows[0]["id_uplatnice"]; uplatnica.IznosUplate = (decimal)dt.Rows[0]["iznos_uplate"]; uplatnica.DatumPrometa = (DateTime)dt.Rows[0]["datum_prometa"]; uplatnica.SvrhaUplate = (string)dt.Rows[0]["svrha_uplate"]; uplatnica.Uplatilac = (string)dt.Rows[0]["uplatilac"]; uplatnica.Hitno = Convert.ToByte(dt.Rows[0]["hitno"]) == 0 ? false : true; return(uplatnica); } } } } catch (Exception e) { Console.WriteLine(e.StackTrace); } return(null); }
public int Create(Uplatnica uplatnica) { try { using (SqlConnection connection = new SqlConnection(ConnectionString)) { using (SqlCommand cmd = connection.CreateCommand()) { cmd.CommandText = "insert into uplatnica(id_racuna,iznos_uplate,datum_prometa,svrha_uplate,uplatilac) " + "values (@id_racuna,@iznos,@datum,@svrha,@uplatilac); "; cmd.CommandText += "SELECT SCOPE_IDENTITY();"; cmd.Parameters.AddWithValue("@id_racuna", uplatnica.Racun.Id); cmd.Parameters.AddWithValue("@iznos", uplatnica.IznosUplate); cmd.Parameters.AddWithValue("@datum", uplatnica.DatumPrometa); cmd.Parameters.AddWithValue("@svrha", uplatnica.SvrhaUplate); cmd.Parameters.AddWithValue("@uplatilac", uplatnica.Uplatilac); connection.Open(); var id = cmd.ExecuteScalar(); if (id != null) { return(int.Parse(id.ToString())); } } } } catch (Exception e) { Console.WriteLine(e.StackTrace); } return(-1); }
public void Edit(Uplatnica uplatnica) { db.Entry(uplatnica).State = EntityState.Modified; db.SaveChanges(); db.Entry(uplatnica).Reference(x => x.Racun).Load(); }
public void Create(Uplatnica uplatnica, int id) { uplatnica.RacunId = id; db.Uplatnice.Add(uplatnica); db.SaveChanges(); }
public ActionResult Update(int id) { Uplatnica uplatnica = UplatnicaRepo.GetById(id); return(View(uplatnica)); }