public static string Create(SiteSettings ss)
        {
            var groupModel = new GroupModel(ss, 0, setByForm: true);
            var invalid    = GroupValidators.OnCreating(ss, groupModel);

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

            default: return(invalid.MessageJson());
            }
            var error = groupModel.Create(ss);

            if (error.Has())
            {
                return(error.MessageJson());
            }
            else
            {
                return(EditorResponse(
                           ss,
                           groupModel,
                           Messages.Created(groupModel.Title.Value),
                           GetSwitchTargets(ss, groupModel.GroupId).Join()).ToJson());
            }
        }
Exemple #2
0
        public static string Create(SiteSettings ss)
        {
            var groupModel = new GroupModel(ss, 0, setByForm: true);
            var invalid    = GroupValidators.OnCreating(ss, groupModel);

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

            default: return(invalid.MessageJson());
            }
            var error = groupModel.Create(ss);

            switch (error)
            {
            case Error.Types.None:
                Sessions.Set("Message", Messages.Created(groupModel.Title.Value));
                return(new ResponseCollection()
                       .SetMemory("formChanged", false)
                       .Href(Locations.Edit(
                                 controller: Routes.Controller(),
                                 id: ss.Columns.Any(o => o.Linking)
                                ? Forms.Long("LinkId")
                                : groupModel.GroupId))
                       .ToJson());

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