Exemplo n.º 1
0
        public ActionResult Save(Models.Loss loss)
        {
            var obj = new { code = "0000", msg = "" };

            if (loss.action == "editLoss")
            {
                var data = dbContext.Loss.Find(loss.id);
                data.title    = loss.title;
                data.msg      = loss.msg;
                data.status   = loss.status;
                data.imageUrl = loss.imageUrl;
                data.place    = loss.place;
                //修改失物名称
                dbContext.Entry(data).State = System.Data.Entity.EntityState.Modified;
                dbContext.SaveChanges();
            }
            else
            {
                loss.pub_user_code = Session["user_code"].AsString();
                loss.pub_user_name = Session["user_name"].AsString();
                loss.pub_user_type = Session["user_type"].AsString();
                loss.publishDate   = DateTime.Now;
                dbContext.Loss.Add(loss);
                dbContext.SaveChanges();
            }
            return(Json(obj));
        }
Exemplo n.º 2
0
        public ActionResult Save(Models.Damage damage)
        {
            var obj = new { code = "0000", msg = "" };

            if (damage.action == "editDamage")
            {
                var data = dbContext.Damage.Find(damage.id);
                data.title    = damage.title;
                data.msg      = damage.msg;
                data.code     = damage.code;
                data.name     = damage.name;
                data.status   = damage.status;
                data.imageUrl = damage.imageUrl;
                //修改破损信息
                dbContext.Entry(data).State = System.Data.Entity.EntityState.Modified;
                dbContext.SaveChanges();
            }
            else
            {
                damage.pub_user_code = Session["user_code"].AsString();
                damage.pub_user_name = Session["user_name"].AsString();
                damage.pub_user_type = Session["user_type"].AsString();
                damage.publishDate   = DateTime.Now;
                dbContext.Damage.Add(damage);
                dbContext.SaveChanges();
            }
            return(Json(obj));
        }