Ejemplo n.º 1
0
        public HttpResponseMessage InventoryTransfer(InventoryTransferDTO data)
        {
            var response=new IntegrationResponse();
            try
            {

                _log.InfoFormat("Login attempt for {0} - {1} Action=>{2}", data.Credentials.ApiUserName, data.Credentials.IntegrationModule,"inventory transfter request");
                CostCentreLoginResponse loginResponse = _costCentreApplicationService.CostCentreLogin(data.Credentials.ApiUserName, data.Credentials.Password,
                                                                                                 "HQAdmin");
                AuditCCHit(loginResponse.CostCentreId, "Login", "Login attempt for " + data.Credentials.IntegrationModule, loginResponse.ErrorInfo);

                if (loginResponse.CostCentreId == Guid.Empty)
                {
                    response.ErrorInfo = "Invalid user credentials";
                    response.Result = "Error";
                    return Request.CreateErrorResponse(HttpStatusCode.BadRequest, response.ErrorInfo);
                }
                response = _integrationService.ProcessInventory(data);
            }
            catch (Exception ex)
            {
                response.Result = "Error";
                response.ErrorInfo = "Error: An error occurred executing the task.Result details=>" + ex.Message + "Inner Exception:" + (ex.InnerException != null ? ex.InnerException.Message : "");
                _log.Error(string.Format("Error: An error occurred when processing inventory operation for {0}\n", data.Credentials.IntegrationModule), ex);
                return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, response.ErrorInfo);
            }
            if (string.IsNullOrEmpty(response.Result))
            {
                response.Result = "Error";
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, response.ErrorInfo+"\n"+response.ResultInfo);
            }

            return Request.CreateResponse(HttpStatusCode.OK, response);
        }
 public  IntegrationResponse ProcessInventory(InventoryTransferDTO dtos)
 {
     return  _inventoryTransferService.Process(dtos);
 }