public InternalDeliveryCreateRequest(InternalDeliveryCreateModel model) : this()
        {
            if (!string.IsNullOrEmpty(model.Id))
            {
                Id = model.Id;
            }

            Username            = model.Username;
            InvoiceDate         = model.InvoiceDate.ConvertToString();
            TemplateNo          = model.TemplateNo;
            SerialNo            = model.SerialNo;
            InvoiceTypeCode     = model.InvoiceTypeCode;
            TotalPaymentAmount  = model.TotalPaymentAmount;
            DeliveryOrderNumber = model.DeliveryOrderNumber;
            DeliveryOrderDate   = model.DeliveryOrderDate.ConvertToString();
            Note           = model.Note;
            DeliveryBy     = model.DeliveryBy;
            ContractNumber = model.ContractNumber;
            if (model.ContractDate != null)
            {
                ContractDate = model.ContractDate.Value.ConvertToString();
            }

            TransportationMethod = model.TransportationMethod;
            PlaceOfReceipt       = model.PlaceOfReceipt;
            FromWarehouseName    = model.FromWarehouseName;
            ToWarehouseName      = model.ToWarehouseName;
            CointanerNumber      = model.CointanerNumber;
            Details = new List <InternalDeliveryDetail>();
        }
Exemple #2
0
        /// <summary>
        ///     Tạo phiếu xuất kho kiêm vận chuyển nội bộ
        /// </summary>
        /// <param name="authentication"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public MessageResult DeliveryCreate(Authentication authentication,
                                            InternalDeliveryCreateModel model)
        {
            MessageResult result = new MessageResult();

            try
            {
                var token = GetToken(authentication);

                if (!string.IsNullOrEmpty(token))
                {
                    string apiLink = $"{authentication.DomainName}/api/interval-delivery/create";

                    InternalDeliveryCreateRequest request = new InternalDeliveryCreateRequest(model);

                    List <InternalDeliveryDetail> invoiceDetails = new List <InternalDeliveryDetail>();
                    if (model.Details != null)
                    {
                        invoiceDetails.AddRange(model.Details.Select(c => new InternalDeliveryDetail(c)));
                    }

                    request.Details = invoiceDetails;

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

            return(result);
        }