예제 #1
0
        public static string Delete(SiteSettings ss, long wikiId)
        {
            var wikiModel = new WikiModel(ss, wikiId);
            var invalid   = WikiValidators.OnDeleting(ss, wikiModel);

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

            default: return(invalid.MessageJson());
            }
            var error = wikiModel.Delete(ss, notice: true);

            if (error.Has())
            {
                return(error.MessageJson());
            }
            else
            {
                Sessions.Set("Message", Messages.Deleted(wikiModel.Title.Value).Html);
                var res = new WikisResponseCollection(wikiModel);
                res
                .SetMemory("formChanged", false)
                .Href(Locations.ItemIndex(Rds.ExecuteScalar_long(statements:
                                                                 Rds.SelectSites(
                                                                     tableType: Sqls.TableTypes.Deleted,
                                                                     column: Rds.SitesColumn().ParentId(),
                                                                     where : Rds.SitesWhere()
                                                                     .TenantId(Sessions.TenantId())
                                                                     .SiteId(wikiModel.SiteId)))));
                return(res.ToJson());
            }
        }
예제 #2
0
        public static string Delete(IContext context, SiteSettings ss, long wikiId)
        {
            var wikiModel = new WikiModel(context, ss, wikiId);
            var invalid   = WikiValidators.OnDeleting(
                context: context,
                ss: ss,
                wikiModel: wikiModel);

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

            default: return(invalid.MessageJson(context: context));
            }
            var error = wikiModel.Delete(context: context, ss: ss, notice: true);

            switch (error)
            {
            case Error.Types.None:
                SessionUtilities.Set(
                    context: context,
                    message: Messages.Deleted(
                        context: context,
                        data: wikiModel.Title.Value));
                var res = new WikisResponseCollection(wikiModel);
                res
                .SetMemory("formChanged", false)
                .Href(Locations.ItemIndex(
                          context: context,
                          id: Rds.ExecuteScalar_long(
                              context: context,
                              statements: Rds.SelectSites(
                                  tableType: Sqls.TableTypes.Deleted,
                                  column: Rds.SitesColumn().ParentId(),
                                  where : Rds.SitesWhere()
                                  .TenantId(context.TenantId)
                                  .SiteId(wikiModel.SiteId)))));
                return(res.ToJson());

            default:
                return(error.MessageJson(context: context));
            }
        }