Example #1
0
 public LPGalleryCategory Edit(int categoryId, string name)
 {
     ValidateParams(name);
     using (var uow = Update())
     {
         var da = new LPGalleryCategoryDataAccess(uow);
         if (da.Exists(name, categoryId))
         {
             throw new ChalkableException("Category with such name already exists");
         }
         var category = da.GetById(categoryId);
         EnsureModifyPermission(category);
         category.Name = name;
         da.Update(category);
         uow.Commit();
         return(category);
     }
 }
Example #2
0
        public LPGalleryCategory Add(string name)
        {
            Trace.Assert(Context.PersonId.HasValue);
            ValidateParams(name);
            BaseSecurity.EnsureAdminOrTeacher(Context);
            var res = new LPGalleryCategory {
                Name = name, OwnerRef = Context.PersonId.Value
            };

            using (var u = Update())
            {
                var da = new LPGalleryCategoryDataAccess(u);
                if (da.Exists(name, null))
                {
                    throw new ChalkableException("Category with such name already exists");
                }
                da.Insert(res);
                res = da.GetAll().Last();
                u.Commit();
                return(res);
            }
        }