public IHttpActionResult GetGSRNotificationType([FromUri] GetGSRNotificationTypeRequest getGSRNotificationTypeRequest) { var responses = new Responses(); try { if (Utility.UserId < 0) { return(BadRequest(Utility.INVALID_USER)); } if (getGSRNotificationTypeRequest == null) { getGSRNotificationTypeRequest = new GetGSRNotificationTypeRequest(); } var gSRNotificationType = new GSRNotificationType() { GSRNotificationTypeId = getGSRNotificationTypeRequest.GSRNotificationTypeId }; var gSRNotificationTypes = iGSRNotification.GetGSRNotificationType(gSRNotificationType); var gSRNotificationTypeList = new List <GetGSRNotificationTypeResponse>(); foreach (var gSRNotificationTypeDetail in gSRNotificationTypes) { gSRNotificationTypeList.Add(new GetGSRNotificationTypeResponse() { GSRNotificationTypeId = gSRNotificationTypeDetail.GSRNotificationTypeId, GSRNotificationTypeName = gSRNotificationTypeDetail.GSRNotificationTypeName }); } responses.Status = Utility.SUCCESS_STATUS_RESPONSE; responses.Description = "GSRNotificationType retrieved successfully"; responses.Response = gSRNotificationTypeList; } catch (Exception ex) { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while retrieving GSRNotification type."; Utility.WriteLog("GetGSRNotificationType", getGSRNotificationTypeRequest, "Error while retrieving GSRNotification type. (GSRNotificationAdminController)", ex.ToString()); } return(Ok(responses)); }
public IEnumerable <GSRNotificationType> GetGSRNotificationType(GSRNotificationType gSRNotificationType) { using (DemsifyEntities dataContext = new DemsifyEntities()) { var gSRNotificationTypes = dataContext.GSRNotificationTypeGet(gSRNotificationType.GSRNotificationTypeId).ToList(); var gSRNotificationTypeList = new List <GSRNotificationType>(); foreach (var gSRNotificationTypeDetail in gSRNotificationTypes) { gSRNotificationTypeList.Add(new GSRNotificationType() { GSRNotificationTypeId = gSRNotificationTypeDetail.GSRNotificationTypeId, GSRNotificationTypeName = gSRNotificationTypeDetail.GSRNotificationTypeName }); } return(gSRNotificationTypeList); } }