0% found this document useful (0 votes)
21 views

Generic Code

This method takes in a boolean value and generic type T, creates a ResponseWrapper object of type T, and sets the Code, Status, and Message properties of the ResponseWrapper based on the boolean value. It returns the ResponseWrapper object.

Uploaded by

ashish877
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Generic Code

This method takes in a boolean value and generic type T, creates a ResponseWrapper object of type T, and sets the Code, Status, and Message properties of the ResponseWrapper based on the boolean value. It returns the ResponseWrapper object.

Uploaded by

ashish877
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

//private static ResponseWrapper<T> GetWrapper<T>(bool?

val, T model) where T : class


//{
// var responseWrapper = new ResponseWrapper<T>();
// if (val != null && model == null)
// {
// responseWrapper.Code = Convert.ToBoolean(val) ?
(int)Constants.StatusCode.Ok : (int)Constants.StatusCode.InternalServerError;
// responseWrapper.Status = Convert.ToBoolean(val) ?
Constants.MessageStatus.Success : Constants.MessageStatus.Error;
// responseWrapper.Message = Convert.ToBoolean(val) ?
Constants.SuccessMessage : Constants.SqlNotSaved;
// }
// else if (val == null && model != null)
// {
// var type = model.GetType();
// var modelName = type.FullName;
// }
// return responseWrapper;
//}

/// <summary>
/// The GetWrapper
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="val">The val<see cref="bool"/></param>
/// <returns>The <see cref="ResponseWrapper{T}"/></returns>
private static ResponseWrapper<T> GetWrapper<T>(bool val) where T : class
{
var responseWrapper = new ResponseWrapper<T>();
responseWrapper.Code = val ? (int)Constants.StatusCode.Ok :
(int)Constants.StatusCode.InternalServerError;
responseWrapper.Status = val ? Constants.MessageStatus.Success :
Constants.MessageStatus.Error;
responseWrapper.Message = val ? Constants.SuccessMessage :
Constants.SqlNotSaved;
return responseWrapper;
}

You might also like