public ActionResult Accept(int id) { var obj = Properties.FirstOrDefault(a => a.ProId == id); if (obj != null) { obj.isApproved = true; obj.UAOComment = "Approved"; UpdateModel(obj); SContextProp.SaveChanges(); var userId = this.Session["UserId"].ToString(); int userID = Convert.ToInt32(userId); //return Content("the accpted is confirmed"); return(RedirectToAction("index", new { id = userID })); } else { return(Content("It's already accepted ")); } }
public ActionResult AddProperty(Property prop, HttpPostedFileBase file) { //if(ModelState.IsValid) //{ try { if (file != null && file.ContentLength > 0) { //get the name of the uploaded file to store it in the database prop.Photo = file.FileName; string _FileName = Path.GetFileName(file.FileName); string _path = Path.Combine(Server.MapPath("~/UploadFiles"), _FileName); file.SaveAs(_path); } else { prop.Photo = "house.jpg"; } var uid = this.Session["userId"]; prop.OwnerId = Convert.ToInt32(uid); prop.isApproved = true; prop.UAOComment = ""; Properties.Add(prop); SContext.SaveChanges(); } catch (Exception e) { return(Content(e.Message + ":" + e.StackTrace)); } ModelState.Clear(); return(RedirectToAction("AddSuccess", prop)); //} //else //{ // re-display the form // return View(); //} }