Пример #1
0
        public string Edit(FormDataCollection form)
        {
            var retVal = string.Empty;
            var operation = form.Get("oper");
            var id = form.Get("Id").Split(',')[0].ToInt32();
            if (string.IsNullOrEmpty(operation)) return retVal;

            TemplateAdsInfo info;
            switch (operation)
            {
                case "edit":
                    info = CatalogRepository.GetInfo<TemplateAdsInfo>(id);
                    if (info != null)
                    {
                        info.Name = form.Get("Name");
                        CatalogRepository.Update(info);
                    }
                    break;
                case "add":
                    info = new TemplateAdsInfo { Name = form.Get("Name") };
                    CatalogRepository.Create(info);
                    break;
                case "del":
                    CatalogRepository.Delete<TemplateAdsInfo>(id);
                    break;
            }
            StoreData.ReloadData<TemplateAdsInfo>();
            return retVal;
        }
Пример #2
0
 public static int GetTemplateAdsId(string value)
 {
     if (_TemplateAds.IsNullOrEmpty()) _TemplateAds = CatalogRepository.GetAll<TemplateAdsInfo>();
     var entity = _TemplateAds.FirstOrDefault(c => c.Name.Equals(value, StringComparison.CurrentCultureIgnoreCase));
     if (entity == null)
     {
         entity = new TemplateAdsInfo { Name = value };
         entity.Id = CatalogRepository.Create(entity);
         _TemplateAds.Add(entity);
     }
     return entity.Id;
 }