public TimeZoneEntryModel GetTimeZoneInformation(int timeZoneEntryId) { try { var entryData = new Business.TimeZoneEntryMethods().GetTimeZoneInformation(timeZoneEntryId); if (entryData == null) throw new EntryNotFound(); return entryData; } catch (EntryNotFound ex) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound) { Content = new StringContent(string.Format("No Entry with ID = {0}", timeZoneEntryId)), ReasonPhrase = "Entry Not Found" }); } catch (Exception ex) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.ServiceUnavailable) { Content = new StringContent(string.Format("Service is currently unavailable.")), ReasonPhrase = "Service Unavailable " }); } }
public TimeZoneEntryModel GetTimeZoneInformation(int timeZoneEntryId) { try { var userInfo = new UserInformation().GetCurrentUserInformation(); var entryData = new Business.TimeZoneEntryMethods().GetTimeZoneInformation(timeZoneEntryId); if (entryData.UserId != userInfo.UserId) throw new UnAuthorize("User Not Authorize"); return entryData; } catch (EntryNotFound ex) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound) { Content = new StringContent(string.Format("No Entry with ID = {0}", timeZoneEntryId)), ReasonPhrase = "Entry Not Found" }); } catch (UnAuthorize ex) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Unauthorized) { Content = new StringContent(string.Format("You are not authorize.")), ReasonPhrase = "UnAuthorize" }); } catch (Exception ex) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.ServiceUnavailable) { Content = new StringContent(string.Format("Service is currently unavailable.")), ReasonPhrase = "Service Unavailable " }); } }
public List<UserTimeZoneEntryModel> GetUserTimeZoneInformation(int userId, int pageNo, int noOfUserRecords, int timeZoneRecordPageNo, int timeZoneRecordToGet) { try { var userInfo = new UserInformation().GetCurrentUserInformation(); var data = new Business.TimeZoneEntryMethods().GetUserTimeZoneInformation(userId, pageNo, noOfUserRecords, timeZoneRecordPageNo, timeZoneRecordToGet, userInfo.Role); if (data == null) throw new EntryNotFound(); return data; } catch (EntryNotFound ex) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound) { Content = new StringContent(string.Format("No Entry Found.")), ReasonPhrase = "Entry Not Found" }); } catch (Exception ex) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.ServiceUnavailable) { Content = new StringContent(string.Format("Service is currently unavailable.")), ReasonPhrase = "Service Unavailable " }); } }