public async Task <string> ValidateAction(ActionDto actionDto) { if (string.IsNullOrEmpty(actionDto.Id)) { // Check customfields var result = await _actionsService.ActionExists(actionDto.Name); return(result ? $"Action with Name #{actionDto.Name} already exists!" : string.Empty); } else { // Check customfields var result = await _actionsService.GetById(actionDto.Id); if (result?.Name == actionDto.Name) { return(string.Empty); } var exists = await _actionsService.ActionExists(actionDto.Name); return(exists ? $"Action with Name #{actionDto.Name} already exists!" : string.Empty); } }
public async Task <string> ValidateContact(ContactDto contactDto) { // Check customfields foreach (var customFieldValue in contactDto.CustomFieldValues) { var customField = await _customFieldsService.GetById(customFieldValue.CfId); if (customField == null) { return($"CustomField with ID #{customFieldValue.CfId} not found!"); } } // Check actions foreach (var actionValue in contactDto.ActionValues) { var action = await _actionsService.GetById(actionValue.AId); if (action == null) { return($"Action with ID #{actionValue.AId} not found!"); } } return(string.Empty); }
//// GET api/<controller>/5 public async Task <IHttpActionResult> Get(string id) { return(Ok(await _actionsService.GetById(id))); }