示例#1
0
        /// <summary>
        /// Get all InvoiceDetail
        /// </summary>
        /// <returns></returns>
        public ApiResponseViewModel GetAll()
        {
            var result   = new List <InvoiceDetailViewModel>();
            var response = new ApiResponseViewModel
            {
                Code    = CommonConstants.ApiResponseSuccessCode,
                Message = null,
                Result  = null
            };

            try
            {
                result = _InvoiceDetailRepository.GetMulti(m => m.IsActive == true).Select(m => new InvoiceDetailViewModel
                {
                    ID           = m.ID,
                    InvoiceID    = m.InvoiceID,
                    Value        = decimal.Parse(m.Value.ToString()).ToString("###,##"),
                    IsActive     = m.IsActive ?? false,
                    DepartmentID = m.DepartmentID,
                    Department   = m.Department.DepartmentName,
                    CategoryID   = m.CategoryID,
                    Category     = m.Category.CategoryName,
                    TaxValueID   = m.TaxValueID,
                    TaxValue     = m.TaxValue.Value.ToString()
                }).ToList();
                response.Result = result;
            }
            catch (Exception ex)
            {
                response.Code    = CommonConstants.ApiResponseExceptionCode;
                response.Message = CommonConstants.ErrorMessage + " " + ex.Message;
            }
            return(response);
        }
示例#2
0
        /// <summary>
        /// Get all Invoice
        /// </summary>
        /// <returns></returns>
        public ApiResponseViewModel GetAll()
        {
            var result   = new List <InvoiceDetailViewModel>();
            var response = new ApiResponseViewModel
            {
                Code    = CommonConstants.ApiResponseSuccessCode,
                Message = null,
                Result  = null
            };

            try
            {
                var invoiceDetails = _InvoiceDetailRepository.GetMulti(m => m.IsActive == true);
                foreach (var idetail in invoiceDetails)
                {
                    var invoice = _InvoiceRepository.GetMulti(m => m.IsActive == true && m.ID == idetail.InvoiceID).FirstOrDefault();
                    if (invoice != null)
                    {
                        var obj = new InvoiceDetailViewModel
                        {
                            ID          = invoice.ID,
                            InvoiceCode = invoice.InvoiceCode,
                            CreateDate  = invoice.CreatedDate.ToShortDateString(),
                            CustomerID  = int.Parse(invoice.CustomerID.ToString()),
                            Customer    = _CustomerRepository.GetSingleById(int.Parse(invoice.CustomerID.ToString())).CustomerName,
                            Category    = idetail.Category.CategoryName,
                            InOut       = invoice.InOut ?? false,
                            Status      = invoice.Status,
                            Value       = decimal.Parse(idetail.Value.ToString()).ToString("###,##"),
                            IsActive    = idetail.IsActive ?? false,
                            TaxValue    = idetail.TaxValue.Value.ToString()
                                          //InvoiceDetails = _InvoiceDetailRepository.GetListInvoiceDetailsByInvoiceID(idetail.ID)
                        };
                        result.Add(obj);
                    }
                }
                response.Result = result;
            }
            catch (Exception ex)
            {
                response.Code    = CommonConstants.ApiResponseExceptionCode;
                response.Message = CommonConstants.ErrorMessage + " " + ex.Message;
            }
            return(response);
        }