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;

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