Ejemplo n.º 1
0
        public HttpResponseMessage GetCashBonusDrawButtons()
        {
            var dateStart = DateTime.Now;

            _performancelog.Debug($"Start,CashBonusController,GetCashBonusDrawButtons,{string.Empty},{dateStart:hh.mm.ss.ffffff}");
            string userCode;
            HttpResponseMessage httpResponseMessage;

            if (GetUserCode(out userCode, out httpResponseMessage))
            {
                return(httpResponseMessage);
            }
            ErrorMessage error;

            var cashBonusDrawButtons = _cashBonusManager.GetCashBonusDrawButtons(userCode, out error);

            if (!string.IsNullOrEmpty(error.MessageStyle.Message))
            {
                _performancelog.Debug(
                    $"End,CashBonusController,GetCashBonusDrawButtons,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");

                return(Request.CreateResponse(HttpStatusCode.BadRequest,
                                              new ErrorResponse
                {
                    Error = error.MessageStyle,
                }));
            }
            CashBonusDrawButtonsResponseModel response = GetCashBonusDrawModel(cashBonusDrawButtons);

            _performancelog.Debug(
                $"End,CashBonusController,GetCashBonusDrawButtons,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Ejemplo n.º 2
0
        ///// <summary>
        ///// Method to get cash draw types
        ///// </summary>
        ///// <returns>Csh draw button</returns>
        //[Route("UpdateTill")]
        //[HttpGet]
        //[SwaggerResponse(HttpStatusCode.Unauthorized, Type = typeof(ErrorResponse))]
        //[SwaggerResponse(HttpStatusCode.BadRequest, Type = typeof(ErrorResponse))]
        //[SwaggerResponse(HttpStatusCode.Forbidden, Type = typeof(ErrorResponse))]
        //[SwaggerResponse(HttpStatusCode.NotFound, Type = typeof(ErrorResponse))]
        //[SwaggerResponse(HttpStatusCode.OK, Type = typeof(CashDrawButtonsResponseModel))]
        //public HttpResponseMessage UpdateTill()
        //{

        //}

        /*
         * /// <summary>
         * /// Method to complete cash draw
         * /// </summary>
         * /// <param name="cashDraw">Cash draw</param>
         * /// <returns>Receipt</returns>
         * [Route("completeDraw")]
         * [HttpPost]
         * [SwaggerResponse(HttpStatusCode.Unauthorized, Type = typeof(ErrorResponse))]
         * [SwaggerResponse(HttpStatusCode.BadRequest, Type = typeof(ErrorResponse))]
         * [SwaggerResponse(HttpStatusCode.Forbidden, Type = typeof(ErrorResponse))]
         * [SwaggerResponse(HttpStatusCode.NotFound, Type = typeof(ErrorResponse))]
         * [SwaggerResponse(HttpStatusCode.OK, Type = typeof(ReportModel))]
         * public HttpResponseMessage CompleteCashDraw([FromBody] CashDrawButton cashDraw)
         * {
         *     var dateStart = DateTime.Now;
         *     _performancelog.Debug($"Start,CashController,CompleteCashDraw,{string.Empty},{dateStart:hh.mm.ss.ffffff}");
         *     string userCode;
         *     HttpResponseMessage httpResponseMessage;
         *     if (GetUserCode(out userCode, out httpResponseMessage)) return httpResponseMessage;
         *     if (cashDraw == null)
         *     {
         *         return Request.CreateResponse(
         *             HttpStatusCode.BadRequest,
         *             new ErrorResponse
         *             {
         *                 Error = new MessageStyle { Message = Constants.InvalidRequest, MessageType = 0 }
         *             });
         *     }
         *     ErrorMessage error;
         *     int copies;
         *     var fs = _cashManager.CompleteCashDraw(cashDraw, userCode, out copies, out error);
         *     if (!string.IsNullOrEmpty(error.MessageStyle.Message))
         *     {
         *         _performancelog.Debug(
         *             $"End,CashController,CompleteCashDraw,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
         *
         *         return Request.CreateResponse(HttpStatusCode.BadRequest,
         *             new ErrorResponse
         *             {
         *                 Error = error.MessageStyle,
         *             });
         *     }
         *     try
         *     {
         *         var content = Helper.CreateBytes(fs);
         *         var cashDrawReceipt = new ReportModel
         *         {
         *             ReportName = Constants.CashDrawFile,
         *             ReportContent = content,
         *             Copies = copies
         *         };
         *         _performancelog.Debug(
         *             $"End,CashController,CompleteCashDraw,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
         *
         *         return Request.CreateResponse(HttpStatusCode.OK, cashDrawReceipt);
         *     }
         *     catch
         *     {
         *         _performancelog.Debug(
         *             $"End,CashController,CompleteCashDraw,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
         *
         *         return Request.CreateResponse(HttpStatusCode.NotFound, new ErrorResponse
         *         {
         *             Error = new MessageStyle { Message = Resource.Error, MessageType = 0 }
         *         });
         *     }
         * }
         *
         * /// <summary>
         * /// Method to get cash buttons
         * /// </summary>
         * /// <returns>Cash buttons</returns>
         * [Route("getCashButtons")]
         * [HttpGet]
         * [SwaggerResponse(HttpStatusCode.OK, Type = typeof(List<CashButton>))]
         * public HttpResponseMessage GetCashButtons()
         * {
         *     var dateStart = DateTime.Now;
         *     _performancelog.Debug($"Start,CashController,GetCashButtons,{string.Empty},{dateStart:hh.mm.ss.ffffff}");
         *
         *     var cashDrawButtons = _cashManager.GetCashButtons();
         *
         *     _performancelog.Debug(
         *         $"End,CashController,GetCashButtons,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
         *     return Request.CreateResponse(HttpStatusCode.OK, cashDrawButtons);
         * }
         *
         * /// <summary>
         * /// Method to update cash drop tenders
         * /// </summary>
         * /// <param name="cashTender">Cash tenders</param>
         * /// <returns>Tenders</returns>
         * [Route("updateTenders")]
         * [HttpPost]
         * [SwaggerResponse(HttpStatusCode.BadRequest, Type = typeof(ErrorResponse))]
         * [SwaggerResponse(HttpStatusCode.OK, Type = typeof(UpdateCashDropResponseModel))]
         * public HttpResponseMessage UpdateCashDropTenders([FromBody] CashTenderModel cashTender)
         * {
         *     var dateStart = DateTime.Now;
         *     _performancelog.Debug(
         *         $"Start,CashController,UpdateCashDropTenders,{string.Empty},{dateStart:hh.mm.ss.ffffff}");
         *
         *     if (cashTender == null)
         *     {
         *         return Request.CreateResponse(
         *             HttpStatusCode.BadRequest,
         *             new ErrorResponse
         *             {
         *                 Error = new MessageStyle { Message = Resource.InvalidRequest, MessageType = 0 }
         *             });
         *     }
         *
         *     ErrorMessage error;
         *     var tenders = cashTender.Tenders.Select(tender => new Tender
         *     {
         *         Tender_Code = tender.TenderCode,
         *         Amount_Entered = tender.AmountEntered ?? 0
         *     }).ToList();
         *
         *     string userCode;
         *     HttpResponseMessage httpResponseMessage;
         *     if (GetUserCode(out userCode, out httpResponseMessage)) return httpResponseMessage;
         *
         *     var updatedTenders = _cashManager.UpdateCashDropTendered(tenders, cashTender.DropReason,
         *         cashTender.SaleNumber, cashTender.TillNumber, userCode, out error);
         *     if (!string.IsNullOrEmpty(error.MessageStyle.Message))
         *     {
         *         _performancelog.Debug(
         *             $"End,CashController,UpdateCashDropTenders,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
         *
         *         return Request.CreateResponse(HttpStatusCode.BadRequest,
         *             new ErrorResponse
         *             {
         *                 Error = error.MessageStyle,
         *             });
         *     }
         *     UpdateCashDropResponseModel response = GetUpdatedTenders(updatedTenders);
         *
         *     _performancelog.Debug(
         *         $"End,CashController,UpdateCashDropTenders,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
         *     return Request.CreateResponse(HttpStatusCode.OK, response);
         * }
         *
         * /// <summary>
         * /// Method to complete cash drop
         * /// </summary>
         * /// <param name="cashDrop">Cash drop</param>
         * /// <returns>Receipt</returns>
         * [Route("completeDrop")]
         * [HttpPost]
         * [SwaggerResponse(HttpStatusCode.Unauthorized, Type = typeof(ErrorResponse))]
         * [SwaggerResponse(HttpStatusCode.BadRequest, Type = typeof(ErrorResponse))]
         * [SwaggerResponse(HttpStatusCode.Forbidden, Type = typeof(ErrorResponse))]
         * [SwaggerResponse(HttpStatusCode.NotFound, Type = typeof(ErrorResponse))]
         * [SwaggerResponse(HttpStatusCode.OK, Type = typeof(ReportModel))]
         * public HttpResponseMessage CompleteCashDrop([FromBody] CashDropModel cashDrop)
         * {
         *     var dateStart = DateTime.Now;
         *     _performancelog.Debug($"Start,CashController,CompleteCashDrop,{string.Empty},{dateStart:hh.mm.ss.ffffff}");
         *     string userCode;
         *     HttpResponseMessage httpResponseMessage;
         *     if (GetUserCode(out userCode, out httpResponseMessage)) return httpResponseMessage;
         *     if (cashDrop == null)
         *     {
         *         return Request.CreateResponse(
         *             HttpStatusCode.BadRequest,
         *             new ErrorResponse
         *             {
         *                 Error = new MessageStyle { Message = "Request is Invalid", MessageType = 0 }
         *             });
         *     }
         *     ErrorMessage error;
         *     var tenders = cashDrop.Tenders.Select(tender => new Tender
         *     {
         *         Tender_Code = tender.TenderCode,
         *         Amount_Entered = tender.AmountEntered
         *     }).ToList();
         *     int copies;
         *     var fs = _cashManager.CompleteCashDrop(tenders, cashDrop.TillNumber, userCode,
         *         cashDrop.RegisterNumber, cashDrop.DropReason, cashDrop.EnvelopeNumber, out copies, out error);
         *     if (!string.IsNullOrEmpty(error.MessageStyle.Message))
         *     {
         *         _performancelog.Debug(
         *             $"End,CashController,CompleteCashDrop,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
         *
         *         return Request.CreateResponse(HttpStatusCode.BadRequest,
         *             new ErrorResponse
         *             {
         *                 Error = error.MessageStyle,
         *             });
         *     }
         *     try
         *     {
         *         var content = Helper.CreateBytes(fs);
         *
         *         var cashDrawReceipt = new ReportModel
         *         {
         *             ReportName = Constants.CashDropFile,
         *             ReportContent = content,
         *             Copies = copies
         *         };
         *
         *         _performancelog.Debug(
         *             $"End,CashController,CompleteCashDrop,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
         *         return Request.CreateResponse(HttpStatusCode.OK, cashDrawReceipt);
         *     }
         *     catch
         *     {
         *         _performancelog.Debug(
         *             $"End,CashController,CompleteCashDrop,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
         *
         *         return Request.CreateResponse(HttpStatusCode.NotFound, new ErrorResponse
         *         {
         *             Error = new MessageStyle { Message = Resource.Error, MessageType = 0 }
         *         });
         *     }
         * }
         *
         * /// <summary>
         * /// Method to save cash draw open reason
         * /// </summary>
         * /// <param name="cashDrop">Cash drop</param>
         * /// <returns>Success Response</returns>
         * [Route("openCashDrawer")]
         * [HttpPost]
         * [SwaggerResponse(HttpStatusCode.BadRequest, Type = typeof(ErrorResponse))]
         * [SwaggerResponse(HttpStatusCode.OK, Type = typeof(SuccessReponse))]
         * public HttpResponseMessage OpenCashDrawer([FromBody] CashDropModel cashDrop)
         * {
         *     var dateStart = DateTime.Now;
         *     _performancelog.Debug($"Start,CashController,OpenCashDrawer,{string.Empty},{dateStart:hh.mm.ss.ffffff}");
         *     string userCode;
         *     HttpResponseMessage httpResponseMessage;
         *     if (GetUserCode(out userCode, out httpResponseMessage)) return httpResponseMessage;
         *     if (cashDrop == null)
         *     {
         *         return Request.CreateResponse(
         *             HttpStatusCode.BadRequest,
         *             new ErrorResponse
         *             {
         *                 Error = new MessageStyle { Message = Constants.InvalidRequest, MessageType = 0 }
         *             });
         *     }
         *     ErrorMessage error;
         *     _cashManager.OpenCashDrawer(userCode, cashDrop.DropReason, cashDrop.TillNumber, out error);
         *     if (!string.IsNullOrEmpty(error.MessageStyle.Message))
         *     {
         *         return Request.CreateResponse(error.StatusCode,
         *             new ErrorResponse
         *             {
         *                 Error = error.MessageStyle,
         *             });
         *     }
         *     var success = new SuccessReponse
         *     {
         *         Success = true
         *     };
         *     _performancelog.Debug(
         *         $"End,CashController,OpenCashDrawer,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
         *     return Request.CreateResponse(HttpStatusCode.OK, success);
         * }
         *
         #region Private methods
         */
        /// <summary>
        /// Method to create cash draw model
        /// </summary>
        /// <param name="cashBonusDrawButtons">Cash draw buttons</param>
        /// <returns>Cash draw button response</returns>
        private CashBonusDrawButtonsResponseModel GetCashBonusDrawModel(CashBonusDrawButton cashBonusDrawButtons)
        {
            var response = new CashBonusDrawButtonsResponseModel();

            foreach (var coin in cashBonusDrawButtons.Coins)
            {
                response.Coins.Add(new CashBonusModel
                {
                    CurrencyName = coin.CurrencyName,
                    Value        = coin.Value,
                    ButtonNumber = coin.ButtonNumber
                });
            }



            return(response);
        }