Example #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;

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