/// <summary>
        /// Fixed:
        /// </summary>
        public static string DeleteTenantImage(Context context, TenantModel tenantModel)
        {
            var ss      = SiteSettingsUtilities.TenantsSiteSettings(context);
            var invalid = BinaryValidators.OnDeletingTenantImage(
                context: context,
                ss: ss);

            switch (invalid)
            {
            case Error.Types.None: break;

            default: return(invalid.MessageJson(context: context));
            }
            var error = new BinaryModel(tenantModel.TenantId)
                        .DeleteTenantImage(context: context);

            if (error.Has())
            {
                return(error.MessageJson(context: context));
            }
            else
            {
                return(new ResponseCollection()
                       .ReplaceAll(
                           "#Logo",
                           new HtmlBuilder().HeaderLogo(
                               context: context))
                       .ReplaceAll(
                           "#TenantImageSettingsEditor",
                           new HtmlBuilder().TenantImageSettingsEditor(
                               context: context, tenantModel: tenantModel))
                       .Message(Messages.FileDeleteCompleted(context: context))
                       .ToJson());
            }
        }
Example #2
0
        /// <summary>
        /// Fixed:
        /// </summary>
        public static string DeleteSiteImage(SiteModel siteModel)
        {
            siteModel.SiteSettings = SiteSettingsUtilities.Get(siteModel, siteModel.SiteId);
            var invalid = BinaryValidators.OnDeletingSiteImage(siteModel.SiteSettings);

            switch (invalid)
            {
            case Error.Types.None: break;

            default: return(invalid.MessageJson());
            }
            var error = new BinaryModel(siteModel.SiteId).DeleteSiteImage();

            if (error.Has())
            {
                return(error.MessageJson());
            }
            else
            {
                return(new ResponseCollection()
                       .Html(
                           "#SiteImageIconContainer",
                           new HtmlBuilder().SiteImageIcon(
                               ss: siteModel.SiteSettings,
                               siteId: siteModel.SiteId))
                       .Html(
                           "#SiteImageSettingsEditor",
                           new HtmlBuilder().SiteImageSettingsEditor(
                               ss: siteModel.SiteSettings))
                       .Message(Messages.FileDeleteCompleted())
                       .ToJson());
            }
        }
Example #3
0
        /// <summary>
        /// Fixed:
        /// </summary>
        public static string UpdateSiteImage(Context context, SiteModel siteModel)
        {
            siteModel.SiteSettings = SiteSettingsUtilities.Get(
                context: context,
                siteModel: siteModel,
                referenceId: siteModel.SiteId);
            var bin     = context.PostedFiles.FirstOrDefault()?.Byte();
            var invalid = BinaryValidators.OnUploadingSiteImage(
                context: context,
                ss: siteModel.SiteSettings,
                bin: bin);

            switch (invalid)
            {
            case Error.Types.None: break;

            default: return(invalid.MessageJson(context: context));
            }
            var error = new BinaryModel(siteModel.SiteId).UpdateSiteImage(
                context: context,
                ss: siteModel.SiteSettings,
                bin: bin);

            if (error.Has())
            {
                return(error.MessageJson(context: context));
            }
            else
            {
                return(new ResponseCollection()
                       .Html(
                           "#TenantImageLogoContainer",
                           new HtmlBuilder().SiteImageIcon(
                               context: context,
                               ss: siteModel.SiteSettings,
                               siteId: siteModel.TenantId))
                       .Html(
                           "#TenantImageSettingsEditor",
                           new HtmlBuilder().SiteImageSettingsEditor(
                               context: context,
                               ss: siteModel.SiteSettings))
                       .Message(Messages.FileUpdateCompleted(context: context))
                       .ToJson());
            }
        }
Example #4
0
        /// <summary>
        /// Fixed:
        /// </summary>
        public static string UpdateSiteImage(Context context, SiteModel siteModel)
        {
            siteModel.SiteSettings = SiteSettingsUtilities.Get(
                context: context,
                siteModel: siteModel,
                referenceId: siteModel.SiteId);
            var file    = Forms.File(Libraries.Images.ImageData.Types.SiteImage.ToString());
            var invalid = BinaryValidators.OnUploadingSiteImage(
                context: context,
                ss: siteModel.SiteSettings,
                file: file);

            switch (invalid)
            {
            case Error.Types.None: break;

            default: return(invalid.MessageJson());
            }
            var error = new BinaryModel(siteModel.SiteId).UpdateSiteImage(
                context: context, file: file);

            if (error.Has())
            {
                return(error.MessageJson());
            }
            else
            {
                return(new ResponseCollection()
                       .Html(
                           "#SiteImageIconContainer",
                           new HtmlBuilder().SiteImageIcon(
                               context: context,
                               ss: siteModel.SiteSettings,
                               siteId: siteModel.SiteId))
                       .Html(
                           "#SiteImageSettingsEditor",
                           new HtmlBuilder().SiteImageSettingsEditor(
                               context: context,
                               ss: siteModel.SiteSettings))
                       .Message(Messages.FileUpdateCompleted())
                       .ToJson());
            }
        }
Example #5
0
        /// <summary>
        /// Fixed:
        /// </summary>
        public static string UpdateSiteImage(SiteModel siteModel)
        {
            siteModel.SiteSettings = SiteSettingsUtilities.Get(siteModel, siteModel.SiteId);
            var invalid = BinaryValidators.OnUpdating(siteModel.SiteSettings);

            switch (invalid)
            {
            case Error.Types.None: break;

            default: return(invalid.MessageJson());
            }
            var error = new BinaryModel(siteModel.SiteId).UpdateSiteImage(
                Forms.File(Libraries.Images.ImageData.Types.SiteImage.ToString()));

            if (error.Has())
            {
                return(error.MessageJson());
            }
            else
            {
                return(Messages.ResponseFileUpdateCompleted().ToJson());
            }
        }