Beispiel #1
0
        public static string Delete(SiteSettings ss, int deptId)
        {
            var deptModel = new DeptModel(ss, deptId);
            var invalid   = DeptValidators.OnDeleting(ss, deptModel);

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

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

            if (error.Has())
            {
                return(error.MessageJson());
            }
            else
            {
                Sessions.Set("Message", Messages.Deleted(deptModel.Title.Value).Html);
                var res = new DeptsResponseCollection(deptModel);
                res
                .SetMemory("formChanged", false)
                .Href(Locations.Index("Depts"));
                return(res.ToJson());
            }
        }