Пример #1
0
        public HttpResponseMessage SaveDailyClosing(DailyClosing closingDetails)
        {
            try
            {
                return(Request.CreateResponse(HttpStatusCode.OK, this.it2Business.SaveDailyClosing(closingDetails, closingDetails.OfficeNumber, closingDetails.UserId)));
            }
            catch (NHibernate.Exceptions.GenericADOException genericAdoException)
            {
                var msg = genericAdoException.InnerException;

                if (msg.ToString().Contains("Violation of UNIQUE KEY constraint 'AK_DayClose_OfficeNum_TransDate'"))
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, this.it2Business.HandleDuplicateDayClosingTransactionDate(closingDetails.OfficeNumber)));
                }

                var error = string.Format("GetDailyClosing(postingDate = {0}, {1}, {2}", closingDetails.PostingDate, "\n", genericAdoException);
                return(HandleExceptions.LogExceptions(error, Logger, genericAdoException));
            }
            catch (ObjectNotFoundException e)
            {
                Logger.Error(string.Format("SaveDailyClosing(postingDate = {0}, {1}, {2}", closingDetails.PostingDate, "\n", e));
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }
            catch (Exception ex)
            {
                var msg = string.Format("GetDailyClosing(postingDate = {0}, {1}, {2}", closingDetails.PostingDate, "\n", ex);
                return(HandleExceptions.LogExceptions(msg, Logger, ex));
            }
        }
Пример #2
0
 public HttpResponseMessage GetDailyClosing([FromUri] DailyClosing dailyClosing)
 {
     try
     {
         return(Request.CreateResponse(HttpStatusCode.OK, this.it2Business.GetDailyClosing(dailyClosing.OfficeNumber, dailyClosing.PostingDate, dailyClosing.UnclosedDaysCount)));
     }
     catch (ObjectNotFoundException e)
     {
         Logger.Error(string.Format("GetDailyClosing(postingDate = {0}, {1}, {2}", dailyClosing.PostingDate, "\n", e));
         return(Request.CreateResponse(HttpStatusCode.NotFound));
     }
     catch (Exception ex)
     {
         var msg = string.Format("GetDailyClosing(postingDate = {0}, {1}, {2}", dailyClosing.PostingDate, "\n", ex);
         return(HandleExceptions.LogExceptions(msg, Logger, ex));
     }
 }