Пример #1
0
        private static Collection<KeyValuePair<string, object>> ToKeyValuePairs(Field[] fields)
        {
            Collection<KeyValuePair<string, object>> pairs = new Collection<KeyValuePair<string, object>>();

            foreach (Field field in fields)
            {
                pairs.Add(new KeyValuePair<string, object>(field.Key, field.Value));
            }

            return pairs;
        }
Пример #2
0
        public static void Insert(Field[] fields, int userId, Config config)
        {
            if (userId <= 0)
            {
                throw new InvalidOperationException(Errors.InvalidUserId);
            }

            if (config.DenyAdd)
            {
                throw new MixERPException(Titles.AccessIsDenied);
            }

            FormHelper.InsertRecord(userId, config.TableSchema, config.Table, config.KeyColumn, ToKeyValuePairs(fields));
        }
Пример #3
0
        public static void Update(object id, Field[] fields, int userId, Config config)
        {
            if (config.DenyEdit)
            {
                throw new MixERPException(Titles.AccessIsDenied);
            }

            string[] exclusion = { "" };

            if (!string.IsNullOrWhiteSpace(config.ExcludeEdit))
            {
                exclusion = config.ExcludeEdit.Split(',').Select(x => x.Trim().ToUpperInvariant()).ToArray();
            }

            FormHelper.UpdateRecord(userId, config.TableSchema, config.Table, ToKeyValuePairs(fields), config.KeyColumn, id,
                string.Empty, exclusion);
        }
Пример #4
0
 public JsonResult Update(object id, Field[] fields)
 {
     const int userId = 2;
     FormHandler.Update(id, fields, userId, this.GetConfig());
     return Json("OK", JsonRequestBehavior.DenyGet);
 }
Пример #5
0
 public JsonResult Add(Field[] fields)
 {
     const int userId = 2;
     FormHandler.Insert(fields, userId, this.GetConfig());
     return Json("OK", JsonRequestBehavior.DenyGet);
 }