public IActionResult UpdateEVoucherStatus(UpdateEVoucherStatusRequest _request)
        {
            string APIName = "UpdateEVoucherStatus";

            log.LogInformation($"{APIName}\r\njson={StringHelper.SerializeObject(_request)}");
            try
            {
                var response = repo.EVoucher.UpdateEVoucherStatus(_request);
                if (response.StatusCode == 200)
                {
                    log.LogInformation($"{APIName}\r\n Update Status Success ");
                    return(Ok(response));
                }
                else
                {
                    log.LogError($"{APIName}\r\nStautsCode:{response.StatusCode}\r\nErrorType:{response.ErrorType}" +
                                 $"\r\nErrorMsg:{response.ErrorMessage}");
                    return(StatusCode(response.StatusCode, response.GetError()));
                }
            }
            catch (Exception e)
            {
                log.LogError($"{APIName}\r\n{e}");
                return(StatusCode(500, new Error("internal-error", e.Message)));
            }
        }
Example #2
0
        public UpdateEVoucherStatusResponse UpdateEVoucherStatus(UpdateEVoucherStatusRequest _request)
        {
            UpdateEVoucherStatusResponse response = new UpdateEVoucherStatusResponse();
            var tblEvoucher = (from v in db_Evoucher.TblEvouchers
                               where v.VoucherNo == _request.VoucherNo
                               select v
                               ).FirstOrDefault();

            if (tblEvoucher == null)
            {
                response.StatusCode   = 404;
                response.ErrorType    = "Record-Not Found";
                response.ErrorMessage = "No Voucher Found.";
                return(response);
            }
            tblEvoucher.Status = _request.Status;

            db_Evoucher.SaveChanges();

            response.Updated   = true;
            response.VoucherNo = tblEvoucher.VoucherNo;

            return(response);
        }