Esempio n. 1
0
        public static string Create(SiteSettings ss)
        {
            var deptModel = new DeptModel(ss, 0, setByForm: true);
            var invalid   = DeptValidators.OnCreating(ss, deptModel);

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

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

            if (error.Has())
            {
                return(error.MessageJson());
            }
            else
            {
                return(EditorResponse(
                           ss,
                           deptModel,
                           Messages.Created(deptModel.Title.Value),
                           GetSwitchTargets(ss, deptModel.DeptId).Join()).ToJson());
            }
        }
Esempio n. 2
0
        public static string Create(SiteSettings ss)
        {
            var deptModel = new DeptModel(ss, 0, setByForm: true);
            var invalid   = DeptValidators.OnCreating(ss, deptModel);

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

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

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

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