public override DTO.EditFormData GetData(int id, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            DTO.EditFormData data = new DTO.EditFormData();
            data.Data = new DTO.AVFInwardInvoice();

            //try to get data
            try
            {
                if (id > 0)
                {
                    using (AVFInwardInvoiceMngEntities context = CreateContext())
                    {
                        var invoice = context.AVFInwardInvoiceMng_AVFInwardInvoice_View.FirstOrDefault(o => o.AVFPurchasingInvoiceID == id);
                        if (invoice == null)
                        {
                            throw new Exception("Can not found the invoice to edit");
                        }
                        data.Data = converter.DB2DTO_AVFInwardInvoice(invoice);
                    }
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }
        public override DTO.SearchFormData GetDataWithFilter(System.Collections.Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            DTO.SearchFormData data = new DTO.SearchFormData();
            data.Data = new List <DTO.AVFInwardInvoiceSearchResult>();
            totalRows = 0;

            //try to get data
            try
            {
                using (AVFInwardInvoiceMngEntities context = CreateContext())
                {
                    string AVFSupplierNM = null;
                    string InvoiceNo     = null;

                    if (filters.ContainsKey("AVFSupplierNM") && !string.IsNullOrEmpty(filters["AVFSupplierNM"].ToString()))
                    {
                        AVFSupplierNM = filters["AVFSupplierNM"].ToString().Replace("'", "''");
                    }
                    if (filters.ContainsKey("InvoiceNo") && !string.IsNullOrEmpty(filters["InvoiceNo"].ToString()))
                    {
                        InvoiceNo = filters["InvoiceNo"].ToString().Replace("'", "''");
                    }

                    var dataTest = context.AVFInwardInvoiceMng_function_SearchAVFInwardInvoice(AVFSupplierNM, InvoiceNo, orderBy, orderDirection);
                    totalRows = dataTest.Count();
                    var result = context.AVFInwardInvoiceMng_function_SearchAVFInwardInvoice(AVFSupplierNM, InvoiceNo, orderBy, orderDirection);

                    data.Data = converter.DB2DTO_AVFInwardInvoiceSearchResultList(result.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList());
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }