Пример #1
0
        public ActionResult Delete(int keyValue)
        {
            RepositoryManager repository = new RepositoryManager();
            Expression <Func <ActivePageHomeEntity, bool> > expresion = _ => _.PKID == keyValue;

            try
            {
                var entity = repository.GetEntity <ActivePageHomeEntity>(expresion);

                repository.Delete <ActivePageHomeEntity>(expresion);

                ActivityUnityController activity = new ActivityUnityController();
                activity.RefreshSource(entity.FKActiveID); //刷新活动页缓存

                return(Content(JsonConvert.SerializeObject(new
                {
                    state = "success",
                    message = "操作成功"
                })));
            }
            catch (Exception em)
            {
                return(Content(JsonConvert.SerializeObject(new
                {
                    state = "error",
                    message = em.Message
                })));
            }
        }
Пример #2
0
        public ActionResult Submit(string json, string group, int?fkActivityID, int pkid = 0, int?MenuType = 0)
        {
            if (string.IsNullOrWhiteSpace(json) || string.IsNullOrWhiteSpace(group) || fkActivityID == null || fkActivityID == 0)
            {
                return(Content("null"));
            }

            try
            {
                RepositoryManager       repository = new RepositoryManager();
                ActivePageContentEntity content    = new ActivePageContentEntity();
                try
                {
                    using (var db = repository.BeginTrans())
                    {
                        var activityEntity = db.FindEntity <ActivePageListEntity>(fkActivityID);
                        activityEntity.MenuType = MenuType;
                        db.Update <ActivePageListEntity>(activityEntity);
                        IEnumerable <ActivePageMenuEntity> beforeList = null;
                        if (pkid != 0)
                        {
                            Expression <Func <ActivePageMenuEntity, bool> > expression = _ => _.FKActiveContentID == pkid;
                            beforeList = repository.GetEntityList <ActivePageMenuEntity>(expression);
                            db.Delete <ActivePageMenuEntity>(expression);
                        }
                        else
                        {
                            content.FKActiveID     = fkActivityID;
                            content.GROUP          = group;
                            content.CreateDateTime = DateTime.Now;
                            content.Type           = -2;
                            content.RowType        = 0;
                            content.OrderBy        = 1;
                            content.IsUploading    = false;
                            content.Channel        = "wap";
                            repository.Add <ActivePageContentEntity>(content);
                        }
                        var list = JsonConvert.DeserializeObject <IEnumerable <ActivePageMenuEntity> >(json);
                        foreach (var item in list)
                        {
                            item.FKActiveContentID = content.PKID == 0 ? pkid : content.PKID;
                            item.CreateDateTime    = DateTime.Now;
                            item.UpdateDateTime    = DateTime.Now;
                            db.Insert <ActivePageMenuEntity>(item);
                        }
                        db.Commit();
                        LoggerManager.InsertOplog(new ConfigHistory()
                        {
                            BeforeValue = JsonConvert.SerializeObject(beforeList), AfterValue = JsonConvert.SerializeObject(list), Author = User.Identity.Name, Operation = "菜单配置", ObjectType = "AUCAct"
                        });
                    }
                }
                catch (Exception em)
                {
                    Expression <Func <ActivePageContentEntity, bool> > expre = _ => _.PKID == content.PKID;
                    repository.Delete <ActivePageContentEntity>(expre);
                    throw new Exception("保存菜单明细错误");
                }

                ActivityUnityController activity = new ActivityUnityController();
                activity.RefreshSource(fkActivityID); //刷新活动页缓存

                return(Content(JsonConvert.SerializeObject(new
                {
                    state = "success",
                    message = "操作成功"
                })));
            }
            catch (Exception em)
            {
                return(Content(JsonConvert.SerializeObject(new
                {
                    state = "error",
                    message = em.Message
                })));
            }
        }
Пример #3
0
        public ActionResult SubmitForm(ActivePageTireSizeConfigEntity entity, int?IsTireSize = null)
        {
            if (entity == null || entity?.FKActiveID == 0)
            {
                return(Content(JsonConvert.SerializeObject(new
                {
                    state = "error",
                    message = "信息为空"
                })));
            }

            RepositoryManager repository = new RepositoryManager();

            try
            {
                var activityEntity = repository.GetEntity <ActivePageListEntity>(entity.FKActiveID);
                if (activityEntity != null)
                {
                    activityEntity.IsTireSize = IsTireSize;
                    repository.Update <ActivePageListEntity>(activityEntity);
                }
                if (entity.PKID == 0)
                {
                    entity.CreateDateTime = DateTime.Now;
                    repository.Add <ActivePageTireSizeConfigEntity>(entity);
                    LoggerManager.InsertLog("ActivityPage", new FlashSaleProductOprLog()
                    {
                        OperateUser    = User.Identity.Name,
                        CreateDateTime = DateTime.Now,
                        BeforeValue    = JsonConvert.SerializeObject(""),
                        AfterValue     = JsonConvert.SerializeObject(entity),
                        LogType        = "ActivityPage",
                        LogId          = entity.FKActiveID.ToString(),
                        Operation      = "新增轮胎适配",
                    });
                    // LoggerManager.InsertOplog(new ConfigHistory() { AfterValue = JsonConvert.SerializeObject(entity), Author = User.Identity.Name, Operation = "新增轮胎适配:"+entity.FKActiveID, ObjectType = "AUCAct", ObjectID = entity.PKID.ToString() });
                }
                else
                {
                    var before = repository.GetEntity <ActivePageTireSizeConfigEntity>(entity.PKID);
                    entity.UpdateDateTime = DateTime.Now;
                    repository.Update <ActivePageTireSizeConfigEntity>(entity);
                    LoggerManager.InsertLog("ActivityPage", new FlashSaleProductOprLog()
                    {
                        OperateUser    = User.Identity.Name,
                        CreateDateTime = DateTime.Now,
                        BeforeValue    = JsonConvert.SerializeObject(before),
                        AfterValue     = JsonConvert.SerializeObject(entity),
                        LogType        = "ActivityPage",
                        LogId          = entity.FKActiveID.ToString(),
                        Operation      = "修改轮胎适配",
                    });
                    //LoggerManager.InsertOplog(new ConfigHistory() { BeforeValue=JsonConvert.SerializeObject(before), AfterValue = JsonConvert.SerializeObject(entity), Author = User.Identity.Name, Operation = "修改轮胎适配:" + entity.FKActiveID, ObjectType = "AUCAct", ObjectID = entity.PKID.ToString() });
                }

                ActivityUnityController activity = new ActivityUnityController();
                activity.RefreshSource(entity.FKActiveID); //刷新活动页缓存

                return(Content(JsonConvert.SerializeObject(new
                {
                    state = "success",
                    message = "操作成功"
                })));
            }
            catch (Exception em)
            {
                return(Content(JsonConvert.SerializeObject(new
                {
                    state = "error",
                    message = JsonConvert.SerializeObject(em)
                })));
            }
        }
Пример #4
0
        public ActionResult SubmitForm(ActivePageHomeEntity entity)
        {
            if (entity == null)
            {
                return(Content(JsonConvert.SerializeObject(new
                {
                    state = "error",
                    message = "信息为空"
                })));
            }

            try
            {
                RepositoryManager repository = new RepositoryManager();

                if (entity.PKID == 0)
                {
                    Expression <Func <ActivePageHomeEntity, bool> > checkexpression = o => o.FKActiveID == entity.FKActiveID;
                    var result = repository.GetEntityList(checkexpression)?.ToList();
                    if (result.Count >= 6)
                    {
                        throw new Exception("会场数量最多可配置6个");
                    }

                    entity.CreateDateTime = DateTime.Now;
                    repository.Add <ActivePageHomeEntity>(entity);
                    LoggerManager.InsertLog("ActivityPage", new FlashSaleProductOprLog()
                    {
                        OperateUser    = User.Identity.Name,
                        CreateDateTime = DateTime.Now,
                        BeforeValue    = JsonConvert.SerializeObject(""),
                        AfterValue     = JsonConvert.SerializeObject(entity),
                        LogType        = "ActivityPage",
                        LogId          = entity.FKActiveID.ToString(),
                        Operation      = "新增会场",
                    });
                    // LoggerManager.InsertOplog(new ConfigHistory() { AfterValue = JsonConvert.SerializeObject(entity), Author = User.Identity.Name, Operation = "新增会场:" + entity.BigHomeName, ObjectType = "AUActivity", ObjectID = entity.PKID.ToString() });
                }
                else
                {
                    var before = repository.GetEntity <ActivePageHomeEntity>(entity.PKID);
                    entity.UpdateDateTime = DateTime.Now;
                    repository.Update <ActivePageHomeEntity>(entity);
                    LoggerManager.InsertLog("ActivityPage", new FlashSaleProductOprLog()
                    {
                        OperateUser    = User.Identity.Name,
                        CreateDateTime = DateTime.Now,
                        BeforeValue    = JsonConvert.SerializeObject(before),
                        AfterValue     = JsonConvert.SerializeObject(entity),
                        LogType        = "ActivityPage",
                        LogId          = entity.FKActiveID.ToString(),
                        Operation      = "修改会场",
                    });
                    // LoggerManager.InsertOplog(new ConfigHistory() { BeforeValue = JsonConvert.SerializeObject(before), AfterValue = JsonConvert.SerializeObject(entity), Author = User.Identity.Name, Operation = "修改会场:" + entity.BigHomeName, ObjectType = "AUActivity", ObjectID = entity.PKID.ToString() });
                }

                ActivityUnityController activity = new ActivityUnityController();
                activity.RefreshSource(entity.FKActiveID); //刷新活动页缓存

                return(Content(JsonConvert.SerializeObject(new
                {
                    state = "success",
                    message = "操作成功"
                })));
            }
            catch (Exception em)
            {
                return(Content(JsonConvert.SerializeObject(new
                {
                    state = "error",
                    message = em.Message
                })));
            }
        }