public ActionResult IsActivate()
        {
            SysLog log = null;

            try
            {
                var state  = Convert.ToInt32(Request["state"]);
                int TypeID = state == 0 ? 14 : 15;
                log = new SysLog {
                    Behavior = (Session["Admin"] as AdminInfo).UserName + (state == 0 ? "上架" : "下架") + "了商品", FK_TypeID = TypeID, FK_AdminID = (Session["Admin"] as AdminInfo).AdminID, Parameters = "ProductID,IsDelete", IP = Request.UserHostAddress, CheckInTime = DateTime.Now
                };

                Product pro = db.Product.Find(Convert.ToInt32(Request["ProductID"]));
                pro.IsDelete        = state;
                db.Entry(pro).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                log.IsException = 0; log.Exception = string.Empty;
                db.SysLog.Add(log); db.SaveChanges();

                return(Json(new AjaxResult {
                    state = ResultType.success.ToString(), message = "操作成功!"
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                log.IsException = 1; log.Exception = ex.Message;
                db.SysLog.Add(log); db.SaveChanges();

                return(Json(new AjaxResult {
                    state = ResultType.error.ToString(), message = ex.Message
                }, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #2
0
        public ActionResult Edit(Supermarket.EneityFramework.Type type)
        {
            SysLog log = new SysLog {
                Behavior = (Session["Admin"] as AdminInfo).UserName + "修改了商品类别" + type.TypeName, FK_TypeID = 10, FK_AdminID = (Session["Admin"] as AdminInfo).AdminID, Parameters = "TypeID,TypeName", IP = Request.UserHostAddress, CheckInTime = DateTime.Now
            };

            try
            {
                db.Entry(type).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                log.IsException = 0; log.Exception = string.Empty;
                db.SysLog.Add(log); db.SaveChanges();

                return(Json(new AjaxResult {
                    state = ResultType.success.ToString(), message = "编辑商品成功"
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                log.IsException = 1; log.Exception = ex.Message;
                db.SysLog.Add(log); db.SaveChanges();

                return(Json(new AjaxResult {
                    state = ResultType.error.ToString(), message = ex.Message
                }, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #3
0
        public ActionResult EditUser(User info)
        {
            SysLog log = new SysLog {
                Behavior = (Session["Admin"] as AdminInfo).UserName + "修改了会员" + info.UserName, FK_TypeID = 8, FK_AdminID = (Session["Admin"] as AdminInfo).AdminID, Parameters = "EF.User", IP = Request.UserHostAddress, CheckInTime = DateTime.Now
            };

            try
            {
                info.AlterInTime = DateTime.Now;

                db.Entry(info).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                log.IsException = 0; log.Exception = string.Empty;
                db.SysLog.Add(log); db.SaveChanges();

                return(Json(new AjaxResult {
                    state = ResultType.success.ToString(), message = "编辑会员信息成功!"
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                log.IsException = 1; log.Exception = ex.Message;
                db.SysLog.Add(log); db.SaveChanges();

                return(Json(new AjaxResult {
                    state = ResultType.error.ToString(), message = ex.Message
                }, JsonRequestBehavior.AllowGet));
            }
        }