/// <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());
            }
        }
        /// <summary>
        /// Fixed:
        /// </summary>
        public static string DeleteImage(Context context, string guid)
        {
            var binaryModel = new BinaryModel()
                              .Get(
                context: context,
                where : Rds.BinariesWhere()
                .TenantId(context.TenantId)
                .Guid(guid));
            var ss = new ItemModel(
                context: context,
                referenceId: binaryModel.ReferenceId)
                     .GetSite(
                context: context,
                initSiteSettings: true)
                     .SiteSettings;
            var invalid = BinaryValidators.OnDeletingImage(
                context: context,
                ss: ss,
                binaryModel: binaryModel);

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

            default: return(invalid.MessageJson(context: context));
            }
            binaryModel.Delete(context: context);
            return(new ResponseCollection()
                   .Message(Messages.DeletedImage(context: context))
                   .Remove($"#ImageLib .item[data-id=\"{guid}\"]")
                   .ToJson());
        }
Example #3
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 #4
0
 public void SetByModel(BinaryModel binaryModel)
 {
     TenantId        = binaryModel.TenantId;
     ReferenceId     = binaryModel.ReferenceId;
     Guid            = binaryModel.Guid;
     BinaryType      = binaryModel.BinaryType;
     Title           = binaryModel.Title;
     Body            = binaryModel.Body;
     Bin             = binaryModel.Bin;
     Thumbnail       = binaryModel.Thumbnail;
     Icon            = binaryModel.Icon;
     FileName        = binaryModel.FileName;
     Extension       = binaryModel.Extension;
     Size            = binaryModel.Size;
     ContentType     = binaryModel.ContentType;
     BinarySettings  = binaryModel.BinarySettings;
     Comments        = binaryModel.Comments;
     Creator         = binaryModel.Creator;
     Updator         = binaryModel.Updator;
     CreatedTime     = binaryModel.CreatedTime;
     UpdatedTime     = binaryModel.UpdatedTime;
     VerUp           = binaryModel.VerUp;
     Comments        = binaryModel.Comments;
     ClassHash       = binaryModel.ClassHash;
     NumHash         = binaryModel.NumHash;
     DateHash        = binaryModel.DateHash;
     DescriptionHash = binaryModel.DescriptionHash;
     CheckHash       = binaryModel.CheckHash;
     AttachmentsHash = binaryModel.AttachmentsHash;
 }
Example #5
0
        /// <summary>
        /// Fixed:
        /// </summary>
        public static (byte[] bytes, string contentType) TenantImageLogo(Context context, TenantModel tenantModel)
        {
            var ss      = SiteSettingsUtilities.TenantsSiteSettings(context);
            var invalid = BinaryValidators.OnGetting(
                context: context,
                ss: ss);

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

            default: return(null, null);
            }
            var binaryModel = new BinaryModel(
                context: context,
                referenceId: tenantModel.TenantId,
                binaryType: "TenantImage");

            return(
                binaryModel.TenantImage(
                    context: context,
                    sizeType: Libraries.Images.ImageData.SizeTypes.Logo,
                    column: Rds.BinariesColumn().Bin()),
                binaryModel.ContentType.IsNullOrEmpty()
                    ? "image/bmp"
                    : binaryModel.ContentType);
        }
Example #6
0
        /// <summary>
        /// Fixed:
        /// </summary>
        public static (byte[] bytes, string contentType) SiteImageIcon(Context context, SiteModel siteModel)
        {
            siteModel.SiteSettings = SiteSettingsUtilities.Get(
                context: context,
                siteModel: siteModel,
                referenceId: siteModel.SiteId);
            var invalid = BinaryValidators.OnGetting(
                context: context,
                ss: siteModel.SiteSettings);

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

            default: return(null, null);
            }
            var binaryModel = new BinaryModel(
                context: context,
                referenceId: siteModel.SiteId,
                binaryType: "SiteImage");

            return(
                binaryModel.SiteImage(
                    context: context,
                    sizeType: Libraries.Images.ImageData.SizeTypes.Icon,
                    column: Rds.BinariesColumn().Icon()),
                binaryModel.ContentType.IsNullOrEmpty()
                    ? "image/bmp"
                    : binaryModel.ContentType);
        }
Example #7
0
 /// <summary>
 /// Fixed:
 /// </summary>
 public static Error.Types OnDeletingImage(SiteSettings ss, BinaryModel binaryModel)
 {
     if (!ss.CanUpdate())
     {
         return(Error.Types.HasNotPermission);
     }
     if (binaryModel.AccessStatus != Databases.AccessStatuses.Selected)
     {
         return(Error.Types.NotFound);
     }
     return(Error.Types.None);
 }
Example #8
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 #9
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 #10
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());
            }
        }
Example #11
0
 public void SetByModel(BinaryModel binaryModel)
 {
     TenantId       = binaryModel.TenantId;
     ReferenceId    = binaryModel.ReferenceId;
     Guid           = binaryModel.Guid;
     BinaryType     = binaryModel.BinaryType;
     Title          = binaryModel.Title;
     Body           = binaryModel.Body;
     Bin            = binaryModel.Bin;
     Thumbnail      = binaryModel.Thumbnail;
     Icon           = binaryModel.Icon;
     FileName       = binaryModel.FileName;
     Extension      = binaryModel.Extension;
     Size           = binaryModel.Size;
     ContentType    = binaryModel.ContentType;
     BinarySettings = binaryModel.BinarySettings;
     Comments       = binaryModel.Comments;
     Creator        = binaryModel.Creator;
     Updator        = binaryModel.Updator;
     CreatedTime    = binaryModel.CreatedTime;
     UpdatedTime    = binaryModel.UpdatedTime;
     VerUp          = binaryModel.VerUp;
     Comments       = binaryModel.Comments;
 }