Example #1
0
        public GetEVoucherDetailResponse GetEvoucherDetail(GetEVoucherDetailRequest _request)
        {
            GetEVoucherDetailResponse response = new GetEVoucherDetailResponse();

            response = (from e in db_Evoucher.TblEvouchers
                        where e.VoucherNo == _request.VoucherNo
                        select new GetEVoucherDetailResponse
            {
                BuyType = e.BuyType,
                Description = e.Description,
                ExpiryDate = e.ExpiryDate,
                GiftPerUserLimit = e.GiftPerUserLimit,
                Image = Path.Combine(configuration["BaseURL"], e.ImagePath),
                MaxLimit = e.MaxLimit,
                PaymentMethod = e.PaymentMethod,
                Quantity = e.Quantity,
                SellingDiscount = e.SellingDiscount,
                SellingPrice = e.SellingPrice,
                Status = e.Status,
                Title = e.Title,
                VoucherAmount = e.VoucherAmount,
                VoucherNo = e.VoucherNo
            }
                        ).FirstOrDefault();

            return(response);
        }
        public IActionResult GetEvoucherDetail([FromQuery] GetEVoucherDetailRequest _request)
        {
            string APIName = "SubmitEVoucher";

            log.LogInformation($"{APIName}\r\njson={StringHelper.SerializeObject(_request)}");
            try
            {
                var response = repo.EVoucher.GetEvoucherDetail(_request);
                if (response != null)
                {
                    log.LogInformation($"{APIName}\r\n Submit Success ");
                    return(Ok(response));
                }
                else
                {
                    log.LogError($"{APIName}\r\nStautsCode:404\r\nErrorType:Record Not Found");
                    return(NotFound(new Error("RecordNotFound", "Record Not Found")));
                }
            }
            catch (Exception e)
            {
                log.LogError($"{APIName}\r\n{e}");
                return(StatusCode(500, new Error("internal-error", e.Message)));
            }
        }