Exemplo n.º 1
0
        public static string Save(Models.Carousel carousel, string userId = null)
        {
            userId            = string.IsNullOrEmpty(userId) ? CoreServices.Account.CurrentIdentityName : userId;
            carousel.PortalId = string.IsNullOrEmpty(carousel.PortalId) ? CoreServices.Portal.CurrentPortalId : carousel.PortalId;
            Validate(carousel);
            var res = CoreServices.Repository.Current.StoreResource("Carousel", null, carousel, userId);

            return(res.Id);
        }
Exemplo n.º 2
0
 public static void Validate(Models.Carousel carousel)
 {
     if (string.IsNullOrEmpty(carousel.Name))
     {
         throw new Exception(CoreServices.Localization.GetExceptionText("InvalidResource.Error", "{0} is invalid.", "Carousel"));
     }
     if (Exists(carousel))
     {
         throw new Exception(CoreServices.Localization.GetExceptionText("DuplicateResource.Error", "{0} already exists.   Duplicates Not Allowed.", "Carousel"));
     }
 }
Exemplo n.º 3
0
        public static string Import(string portalId, Models.Carousel carousel, string userId = null)
        {
            userId = string.IsNullOrEmpty(userId) ? Account.AuditId : userId;
            var existing = Get(portalId, carousel.Name);

            if (existing != null)
            {
                carousel.Id = existing.Id;
            }
            else
            {
                carousel.Id = null;
            }
            carousel.PortalId = portalId;
            return(Save(carousel, userId));
        }
Exemplo n.º 4
0
        public static bool Exists(Models.Carousel carousel)
        {
            var existingCarousel = Get(carousel.PortalId, carousel.Name);

            return(existingCarousel != null && existingCarousel.Name == carousel.Name && existingCarousel.Id != carousel.Id);
        }