Esempio n. 1
0
        public HttpResponseMessage Post(string officeNumber, [FromBody] MarketingRecall marketingRecall)
        {
            var recallIt2Manager = new RecallReportsIt2Manager();

            try
            {
                var isProcessing = recallIt2Manager.ValidateRecallReport(officeNumber, marketingRecall);
                if (isProcessing)
                {
                    const string ValidationString = "A report for this recall type and date range has already been generated. Select a different date range.";
                    return(this.Request.CreateResponse(HttpStatusCode.BadRequest, new { validationmessage = ValidationString }));
                }

                var recall = recallIt2Manager.RunMarketingRecallReport(officeNumber, marketingRecall);
                return(this.Request.CreateResponse(HttpStatusCode.OK, recall));
            }
            catch (ObjectNotFoundException)
            {
                return(this.Request.CreateResponse(HttpStatusCode.NotFound));
            }
            catch (Exception ex)
            {
                var msg = string.Format("Post(id = {0}, {1}, {2}", marketingRecall.Id, "\n", ex);
                return(HandleExceptions.LogExceptions(msg, Logger, ex));
            }
        }
Esempio n. 2
0
        public HttpResponseMessage Put([FromBody] MarketingRecall marketingRecall)
        {
            var recallIt2Manager = new RecallReportsIt2Manager();
            var user             = new AuthorizationTicketHelper().GetUserInfo();
            var officeNumber     = user.OfficeNum;

            try
            {
                var recall = recallIt2Manager.UpdateMarketingRecallReport(marketingRecall, officeNumber);
                return(this.Request.CreateResponse(HttpStatusCode.OK, recall));
            }
            catch (Exception ex)
            {
                var msg = string.Format("Put(id = {0}, {1}, {2}", marketingRecall.Id, "\n", ex);
                return(HandleExceptions.LogExceptions(msg, Logger, ex));
            }
        }