Skip to content

Instantly share code, notes, and snippets.

@dhaniksahni
Created December 17, 2019 16:43
Show Gist options
  • Save dhaniksahni/f6b520b8334d8f51cb15ff878adc3223 to your computer and use it in GitHub Desktop.
Save dhaniksahni/f6b520b8334d8f51cb15ff878adc3223 to your computer and use it in GitHub Desktop.
/******************************************************************************
* Author: Dhanik Lal Sahni
* Date: Oct 8, 2019
* Descpription: Implementation class for IServiceRequest to creating Case.
*/
public class CaseServiceRequest implements IServiceRequest{
//validate information
private string validateServiceRequest(ServiceRequestData data){
string errors='';
if(String.isBlank(data.status))
{
errors=(string.isBlank(errors)?'':errors+',')+'status is mandatory';
}
if(String.isBlank(data.description))
{
errors=(string.isBlank(errors)?'':errors+',')+'description is mandatory';
}
return errors;
}
private string createCase(ServiceRequestData request)
{
Case serviceRequestCase=new Case();
serviceRequestCase.Origin=request.origin;
serviceRequestCase.Subject=request.subject;
insert serviceRequestCase;
return serviceRequestCase.Id;
//Any other implementation can added here or replaced
}
public string createServiceRequest(ServiceRequestData request)
{
string errors=validateServiceRequest(request);
if(string.isNotBlank(errors))
{
throw new BaseException(errors);
}
return createCase(request);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment