//public ActionResult Create([Bind(Include = "ID, name, IsActive, CreatedByDate")] Observation_types observation_Types) public ActionResult Create(Observation_types observation_Types) { if (ModelState.IsValid) // renders false result, why? { db.Observation_types.Add(observation_Types); db.SaveChanges(); // is not working, validation error return(RedirectToAction("Index")); } return(View(observation_Types)); }
//[ValidateAntiForgeryToken] public JsonResult JsonDelete(DeleteSavedProperty model) { HousingHealthDB db = new HousingHealthDB(); var userID = db.Users.Find(User.Identity.GetUserId()); //Paula change bool isDeleted = false; string message; SavedProperties sProp = db.SavedProperties.Find(model.ID); if (sProp == null) { message = "Failed"; return(Json(message, JsonRequestBehavior.AllowGet)); } else { var propDelete = qm.DeleteProperty(model.ID, userID.Id.ToString()); isDeleted = true; } if (isDeleted) { db.SaveChanges(); } message = "Saved Property Has Been Deleted"; return(Json(message, JsonRequestBehavior.AllowGet)); }
public void SaveSearchHistory(int PropertyID, string UserID) { ApplicationUser userRec = db.Users.Find(UserID); var rec = db.SearchHistory.Where(s => s.ID == PropertyID && s.CreatedByUser.Id == userRec.Id).FirstOrDefault(); if (rec == null) { Properties pr = db.Properties.Find(PropertyID); SearchHistory sh = new SearchHistory(); sh.Properties = pr; sh.CreatedByUser = userRec; sh.CreatedByDate = DateTime.Now; sh.IsActive = true; db.SearchHistory.Add(sh); db.SaveChanges(); } }
public ActionResult Create([Bind(Include = "Observation_Types,time_stamp,value")] Observations observations) { if (ModelState.IsValid) { db.Observations.Add(observations); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(observations)); }