Esempio n. 1
0
        public ActionResult Create([Bind(Include = "MarkID,Lat,Lng,Title")] Mark mark)
        {
            if (ModelState.IsValid)
            {
                db.Marks.Add(mark);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(mark));
        }
Esempio n. 2
0
        public JsonResult Create(Mark model)
        {
            MarkDbContext db = new MarkDbContext();

            try
            {
                model.ID = Guid.NewGuid().ToString();
                db.Marks.Add(model);
                db.SaveChanges();
                return(Json(new{ Result = "OK", Records = model }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = "ERROR", Message = ex.Message }));
            }
        }
Esempio n. 3
0
        public JsonResult Edit(Mark model)
        {
            MarkDbContext db = new MarkDbContext();

            try
            {
                db.Entry(model).State = EntityState.Modified;
                db.SaveChanges();
                return(Json(new { Result = "OK" }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = "ERROR", Message = ex.Message }));

                //throw;
            }
        }
Esempio n. 4
0
        public JsonResult Delete(string ID)
        {
            MarkDbContext db = new MarkDbContext();

            try
            {
                //删除,是先找到,在删除
                Mark marks = db.Marks.Find(ID);
                db.Marks.Remove(marks);
                db.SaveChanges();
                return(Json(new { Result = "OK" }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = "ERROR", Message = ex.Message }));
                //throw;
            }
        }