Пример #1
0
        public async Task <IActionResult> GetFormComponentsbyType([FromBody] FormComponentTypeModel model)
        {
            if (ModelState.IsValid)
            {
                FormComponentType type = _repository.GetFormComponentTypebyTypeName(model.FormComponentTypeName);

                if (type == null)
                {
                    return(BadRequest("Invalid FormComponent Type"));
                }

                return(Ok(type.FormComponents));
            }
            return(BadRequest());
        }
Пример #2
0
        public async Task <IActionResult> AddFormComponentType([FromBody] FormComponentTypeModel model)
        {
            if (ModelState.IsValid)
            {
                FormComponentType type = _repository.GetFormComponentTypebyTypeName(model.FormComponentTypeName);

                if (type != null)
                {
                    return(BadRequest("ComponentType already Exists"));
                }

                _repository.AddFormComponentType(model.FormComponentTypeName);

                return(Ok("ComponentType has been created"));
            }
            return(BadRequest());
        }
Пример #3
0
        public async Task <IActionResult> DeleteFormComponentType([FromBody] FormComponentTypeModel model)
        {
            if (ModelState.IsValid)
            {
                FormComponentType type = _repository.GetFormComponentTypebyTypeName(model.FormComponentTypeName);

                if (type == null)
                {
                    return(BadRequest("ComponentType doesn't Exists"));
                }

                if (type.FormComponents.Count() > 0)
                {
                    return(BadRequest("ComponentType Cannot be deleted. There are FormComponents using this Type"));
                }

                _repository.DeleteFormComponentType(model.FormComponentTypeName);

                return(Ok("ComponentType has been Removed"));
            }
            return(BadRequest());
        }