public async Task <IActionResult> CancelInvoice([FromBody] InvoiceCancelModel invoice)
        {
            int CompanyID = 0;

            try
            {
                CompanyID = int.Parse(User.Claims.FirstOrDefault(x => x.Type == "CompanyID").Value);
                return(Ok(await _invoiceRepository.CancelInvoice(CompanyID, invoice.InvoiceID)));
            }
            catch (Exception e)
            {
                _logger.LogError($"Error: {nameof(Create)}: {e.StackTrace}");
                return(BadRequest());
            }
        }
Esempio n. 2
0
        /// <summary>
        ///     Xóa 1 hóa đơn chưa ký
        /// </summary>
        /// <param name="authentication"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public MessageResult Cancel(Authentication authentication,
                                    InvoiceCancelModel model)
        {
            MessageResult result = new MessageResult();

            try
            {
                var token = GetToken(authentication);

                if (!string.IsNullOrEmpty(token))
                {
                    string apiLink = $"{authentication.DomainName}/api/invoices/cancel/{model.Id}";

                    InvoiceCancelRequest request = new InvoiceCancelRequest(model);

                    var rawResponse = AppUtil.CreateRequest(apiLink,
                                                            request.ToJson(),
                                                            token);
                    var response = rawResponse.ToObject <BaseResponse <InvoiceCancelResponse> >();
                    if (response != null)
                    {
                        result.Code      = response.Code;
                        result.Succeeded = response.Succeeded;
                        result.Data      = response.Data;
                    }
                }
                else
                {
                    result.CannotLogin();
                }
            }
            catch (Exception)
            {
                result.ErrorApi();
            }

            return(result);
        }
Esempio n. 3
0
 public InvoiceCancelRequest(InvoiceCancelModel model) : this()
 {
     Id = model.Id;
 }