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()); }
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()); }
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()); }