Created
December 17, 2019 16:43
-
-
Save dhaniksahni/f6b520b8334d8f51cb15ff878adc3223 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/****************************************************************************** | |
* 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