public ActionResult DeleteConfirmed(int id) { SQLData.Stan stan = db.Stans.Find(id); db.Stans.Remove(stan); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,GazdaId,Kvadratura,BrojNaSobi,NaKojSprat,ImaLift,ImaKujna,ImaToalet,ImaTerasa,Namesten,DatumObjaven,KontaktIme,KontaktBroj,Lokacija,Opis,Cena")] SQLData.Stan stan) { if (ModelState.IsValid) { stan.GazdaId = User.Identity.Name; stan.DatumObjaven = DateTime.Now; db.Entry(stan).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(stan)); }
// GET: Stan/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SQLData.Stan stan = db.Stans.Find(id); if (stan == null) { return(HttpNotFound()); } return(View(stan)); }
public ActionResult Create([Bind(Include = "Id,Kvadratura,BrojNaSobi,NaKojSprat,ImaLift,ImaKujna,ImaToalet,ImaTerasa,Namesten,DatumObjaven,KontaktIme,KontaktBroj,Lokacija,Opis,Cena")] SQLData.Stan stan, HttpPostedFileBase file) { if (ModelState.IsValid) { stan.GazdaId = User.Identity.Name; stan.DatumObjaven = DateTime.Now; db.Stans.Add(stan); db.SaveChanges(); if (file != null && file.ContentLength > 0) { //string Filename = stan.Id + "_" + stan.GazdaId + "." + file.FileName.Split('.').Last(); string Filename = stan.Id + "_" + stan.GazdaId + ".jpg"; string SavePath = Server.MapPath("~/Images/") + Filename; Debug.WriteLine("Save: " + SavePath); file.SaveAs(SavePath); } return(RedirectToAction("Index")); } return(View(stan)); }