public IActionResult CheckPromoCode(CheckPromoCodeRequest _request)
        {
            string APIName = "CheckPromoCode";

            log.LogInformation($"{APIName}\r\njson={StringHelper.SerializeObject(_request)}");
            try
            {
                var response = repo.Estore.CheckPromoCode(_request);
                if (response != null)
                {
                    log.LogInformation($"{APIName}\r\n Check PromoCode 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)));
            }
        }
Example #2
0
        public CheckPromoCodeResponse CheckPromoCode(CheckPromoCodeRequest _request)
        {
            var response = (from ge in db_Evoucher.TblGeneratedEvouchers
                            where ge.PromoCode == _request.PromoCode &&
                            ge.ExpiryDate > DateTime.Now &&
                            ge.OwnerPhone == _request.Phone
                            select new CheckPromoCodeResponse
            {
                Status = (PromoCodeStatus)ge.Status,
                PromoAmount = ge.VoncherAmount
            }
                            ).FirstOrDefault();

            if (response == null)
            {
                response = new CheckPromoCodeResponse
                {
                    Status      = PromoCodeStatus.InValid,
                    PromoAmount = 0
                };
            }

            return(response);
        }