public JsonResult FieldGroups(Settings model)
        {
            string msg     = "";
            bool   success = false;

            try
            {
                //fieldgroup
                if (model.TypeGroupField != null && model.TypeGroupField.Count > 0)
                {
                    foreach (var mod in apiHelper.AllModels(true))
                    {
                        var fieldGroupMeta = repo.GetPuckMeta().Where(x => x.Name.StartsWith(DBNames.FieldGroups + mod.Name)).ToList();
                        fieldGroupMeta.ForEach(x =>
                        {
                            repo.DeleteMeta(x);
                        });
                    }
                    model.TypeGroupField.ForEach(x => {
                        var values    = x.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
                        var newMeta   = new PuckMeta();
                        newMeta.Name  = DBNames.FieldGroups + values[0];
                        newMeta.Key   = values[1];
                        newMeta.Value = values[2];
                        repo.AddMeta(newMeta);
                    });
                }

                var    modelTypes = apiHelper.Models();
                string cacheKeys  = "";
                foreach (var modelType in modelTypes)
                {
                    string cacheKey = "fieldGroups_" + modelType.Name;
                    cacheKeys += cacheKey + ",";
                    cache.Remove(cacheKey);
                }
                cacheKeys = cacheKeys.TrimEnd(',');

                var instruction = new PuckInstruction()
                {
                    Count             = modelTypes.Count,
                    ServerName        = ApiHelper.ServerName(),
                    InstructionDetail = cacheKeys,
                    InstructionKey    = InstructionKeys.RemoveFromCache
                };
                repo.AddPuckInstruction(instruction);

                repo.SaveChanges();
                success = true;
            }
            catch (Exception ex)
            {
                msg     = ex.Message;
                success = false;
            }
            return(Json(new { success = success, message = msg }));
        }
Beispiel #2
0
        public JsonResult FieldGroups(Settings model)
        {
            string msg     = "";
            bool   success = false;

            try
            {
                //fieldgroup
                if (model.TypeGroupField != null && model.TypeGroupField.Count > 0)
                {
                    foreach (var mod in apiHelper.AllModels(true))
                    {
                        var fieldGroupMeta = repo.GetPuckMeta().Where(x => x.Name.StartsWith(DBNames.FieldGroups + mod.Name)).ToList();
                        fieldGroupMeta.ForEach(x =>
                        {
                            repo.DeleteMeta(x);
                        });
                    }
                    model.TypeGroupField.ForEach(x => {
                        var values    = x.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
                        var newMeta   = new PuckMeta();
                        newMeta.Name  = DBNames.FieldGroups + values[0];
                        newMeta.Key   = values[1];
                        newMeta.Value = values[2];
                        repo.AddMeta(newMeta);
                    });
                }
                repo.SaveChanges();
                success = true;
            }
            catch (Exception ex)
            {
                msg     = ex.Message;
                success = false;
            }
            return(Json(new { success = success, message = msg }));
        }