コード例 #1
0
        //[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));
        }