Пример #1
0
        private string ValidateCreateModel(CreateUserBindingModel createModel, Role role)
        {
            string msg = String.Empty;

            if (role.Equals(Role.Affiliate))
            {
                int category;
                if (!int.TryParse(createModel.UserCategory, out category))
                {
                    msg = "That is not a valid user category";
                    ModelState.AddModelError("createUserModel.UserCategory", msg);
                }
            }

            if (role.Equals(Role.Vendor))
            {
                if (String.IsNullOrEmpty(createModel.ProgramDescription))
                {
                    msg = "Please enter a Program Description";
                    ModelState.AddModelError("createUserModel.ProgramDescription", msg);
                }

                if (String.IsNullOrEmpty(createModel.ProgramName))
                {
                    msg = "Please enter a Program Name";
                    ModelState.AddModelError("createUserModel.ProgramName", msg);
                }

                Program program = MarketManager.GetAllPrograms().Where(p => p.Name.ToLower() == createModel.ProgramName.ToLower()).FirstOrDefault();
                if (null != program)
                {
                    msg = "That program name is already taken, please enter something different";
                    ModelState.AddModelError("createUserModel.ProgramName", msg);
                }

                int category;
                if (!int.TryParse(createModel.ProgramCategory, out category))
                {
                    msg = "That is not a valid program category";
                    ModelState.AddModelError("createUserModel.ProgramCategory", msg);
                }


                if (String.IsNullOrEmpty(createModel.ProgramUrl))
                {
                    msg = "Please enter a Program Url";
                    ModelState.AddModelError("createUserModel.ProgramUrl", msg);
                }
            }

            return(msg);
        }