コード例 #1
0
        public HttpResponseMessage SetTaxExemption([FromBody] TaxExemptionModel model)
        {
            var dateStart = DateTime.Now;

            _performancelog.Debug($"Start,SaleController,SetTaxExemption,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}");
            string userCode;
            HttpResponseMessage httpResponseMessage;

            if (GetUserCode(out userCode, out httpResponseMessage))
            {
                return(httpResponseMessage);
            }
            ErrorMessage error;
            var          sale = _saleManager.SetTaxExemptionCode(model.SaleNumber, model.TillNumber,
                                                                 userCode, model.TaxExemptionCode, out error);

            if (!string.IsNullOrEmpty(error.MessageStyle.Message))
            {
                return(Request.CreateResponse(
                           HttpStatusCode.NotFound,
                           new ErrorResponse
                {
                    Error = error.MessageStyle
                }));
            }
            if (sale != null)
            {
                var editLines       = _saleManager.CheckEditOptions(sale.Sale_Lines, userCode);
                var enableButtons   = _saleManager.EnableCashButton(sale, userCode);
                var userCanWriteOff = _saleManager.EnableWriteOffButton(userCode);
                var saleModel       = SaleMapper.CreateSaleModel(sale, editLines, enableButtons, userCanWriteOff);
                _performancelog.Debug(
                    $"End,SaleController,SetTaxExemption,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");

                return(Request.CreateResponse(HttpStatusCode.OK, saleModel));
            }
            return(Request.CreateResponse(HttpStatusCode.BadRequest, new ErrorResponse
            {
                Error = new MessageStyle {
                    Message = Resource.SaleNotExist, MessageType = (MessageType)16
                }
            }));
        }