Exemple #1
0
        //[Route("use")]
        //[HttpPut]
        //public HttpResponseMessage UseVoucher(PromotionRequestViewModel model)
        //{
        //    //Logger.Log("Store " + model.terminalId + " - " + (model.Order == null ? "null order" : model.Order.OrderCode + "-" + model.Order.OrderId));
        //    //Logger.Log("|UseVoucherCode| begin method");
        //    try
        //    {
        //        var pDomain = new PromotionDomain();
        //        var voucher = pDomain.GetVoucher(model.VoucherCode);
        //        var available = pDomain.IsVoucherAvailable(voucher);
        //        if (available.Success)
        //        {
        //            var useResult = pDomain.UseVoucher(voucher, model);
        //            //Logger.Log("|UserVoucherCode| result: " + useResult.Message + "-" + useResult.Error, true);
        //            return new HttpResponseMessage()
        //            {
        //                Content = new JsonContent(useResult),
        //                StatusCode = HttpStatusCode.OK
        //            };
        //        }
        //        else
        //        {
        //            return new HttpResponseMessage()
        //            {
        //                Content = new JsonContent(available),
        //                StatusCode = HttpStatusCode.OK
        //            };
        //        }
        //    }
        //    catch (Exception e)
        //    {
        //        //Logger.Log("|UserVoucherCode| error:\r\n" + JsonConvert.SerializeObject(e), true);
        //        var res = new BaseResponse<string>
        //        {
        //            Success = false,
        //            Message = "Có lỗi xảy ra",
        //            Error = "",
        //            ResultCode = (int)DataService.Models.ResultEnum.InternalError
        //        };
        //        return new HttpResponseMessage()
        //        {
        //            Content = new JsonContent(res),
        //            StatusCode = HttpStatusCode.InternalServerError
        //        };
        //    }
        //}
        #endregion

        #region Mapping models
        private void AddInfo(OrderAPIViewModel src, VoucherQueryRequest <List <OrderDetailAPIViewModel> > request)
        {
            if (!request.BrandId.HasValue)
            {
                throw ApiException.Get(false, "Thiếu thông tin hãng", ResultEnum.BrandIdNotFound, HttpStatusCode.BadRequest);
            }
            var prdDomain = new ProductDomain();

            src.BrandId = request.BrandId.Value;
            foreach (var oD in request.Data)
            {
                oD.ProductCode = prdDomain.GetProductById(oD.ProductID).Code;
            }
        }
Exemple #2
0
        private void AddInfo(OrderAPIViewModel src, CheckVoucherViewModel request)
        {
            if (!request.BrandId.HasValue && !request.StoreId.HasValue)
            {
                throw ApiException.Get(false, "Thiếu thông tin brand", ResultEnum.BrandIdNotFound, HttpStatusCode.BadRequest);
            }
            var prdDomain = new ProductDomain();

            src.BrandId = request.BrandId.Value;
            if (request.BrandId == -1 && request.StoreId > 0)
            {
                var storeApi = new DataService.Domain.StoreDomain();
                var store    = storeApi.GetStoreByStoreId(request.StoreId.Value);
                src.BrandId = store.BrandId;
            }
            else
            {
                throw ApiException.Get(false, "Thiếu thông tin brand", ResultEnum.BrandIdNotFound, HttpStatusCode.BadRequest);
            }
            foreach (var oD in request.Data)
            {
                oD.ProductCode = prdDomain.GetProductById(oD.ProductID).Code;
            }
        }