Beispiel #1
0
        public int Insert(ProjectsEntity model)
        {
            this.ClearBrokenRuleMessages();
            BaseValidator <ProjectsEntity> validator = new AddProjectValidator();

            if (!validator.Validate(model))
            {
                this.AddBrokenRuleMessages(validator.BrokenRuleMessages);
                return(0);
            }
            if (projResp.CheckExistsTitle(model.Title, 0))
            {
                this.AddBrokenRuleMessage("Error", "Project title existed!Please input a new one.");
                return(0);
            }
            if (projResp.CheckExistsCode(model.ProjectCode, 0))
            {
                this.AddBrokenRuleMessage("Error", "Project code existed!Please input a new one.");
                return(0);
            }
            int id = projResp.Insert(model);

            if (id <= 0)
            {
                this.AddBrokenRuleMessage();
                return(0);
            }
            model.ProjectID = id;
            model.ID        = id;
            ClearCache();
            return(id);
        }