Ejemplo n.º 1
0
        public skPerson GetPersonObject(int personID)
        {
            AddressRepo repo = new AddressRepo();

            var query = (from A in DB.dtPersons
                         where A.pID == personID
                         select new skPerson
            {
                pID = A.pID,
                EbayName = A.EbayName,
                Email = A.Email,
                FirstName = A.FirstName,
                Surname = A.SureName,
                HomePhone = A.HomePhone,
                WorkPhone = A.WorkPhone,
                LinkedAddresses = repo.GetPersonAddressList(personID).ToList(),
                Created = A.Created,
                Updated = A.Updated
            }).FirstOrDefault();

            if (query == null)
            {
                throw new NoRecordException(typeof(skPerson));
            }
            else
            {
                return(query);
            }
        }
Ejemplo n.º 2
0
        public IEnumerable <skPerson> GetPersonList()
        {
            AddressRepo repo = new AddressRepo();

            var query = from A in DB.dtPersons
                        select new skPerson
            {
                pID             = A.pID,
                EbayName        = A.EbayName,
                Email           = A.Email,
                FirstName       = A.FirstName,
                Surname         = A.SureName,
                HomePhone       = A.HomePhone,
                WorkPhone       = A.WorkPhone,
                LinkedAddresses = repo.GetPersonAddressList(A.pID).ToList(),
                Created         = A.Created,
                Updated         = A.Updated
            };

            return(query);
        }
Ejemplo n.º 3
0
        public skSales GetSalesDetailsByStockID(int stockid)
        {
            AddressRepo AddressRepo = new AddressRepo();

            var query = (from S in DB.dtSales
                         join ST in DB.dtStocks on S.tID equals ST.SaleID
                         join U in DB.dtUsers on S.SoldBy equals U.uID
                         join UD in DB.dtUserDetails on U.uID equals UD.UserID
                         join P in DB.dtPersons on S.PersonID equals P.pID
                         where ST.sID == stockid
                         select new skSales
            {
                ID = S.tID,
                Title = S.Title,
                Description = S.Description,
                Postage = S.PandP,
                Amount = S.SoldValue,
                SaleDate = S.SoldDate,
                PayPalFees = S.PaypayFees,
                PayPalTransactionID = S.PayPalTransactionID,
                Created = S.Created,
                Updated = S.Updated,
                SaleMethod = S.SaleMethod,
                UserObj = new skUser
                {
                    UserID = U.uID,
                    DOB = UD.DateOfBirth,
                    Email = UD.Email,
                    FistName = UD.FirstName,
                    LastName = UD.LastName,
                    HomePhone = UD.HomePhone,
                    Initials = UD.Initials,
                    UserName = U.UserName,
                    WorkPhone = UD.WorkPhone
                },
                PersonObj = new skPerson
                {
                    pID = P.pID,
                    Created = P.Created,
                    EbayName = P.EbayName,
                    Email = P.Email,
                    FirstName = P.FirstName,
                    HomePhone = P.HomePhone,
                    LinkedAddresses = AddressRepo.GetPersonAddressList(P.pID).ToList(),
                    Mobile = P.WorkPhone,
                    WorkPhone = P.WorkPhone,
                    Surname = P.SureName,
                    Updated = P.Updated
                }
            }).FirstOrDefault();

            var stocklist = from SL in DB.dtStocks
                            join ST in DB.dtCategories on SL.CategoryID equals ST.CatID
                            join VB in DB.dtValueBands on SL.ValueBandID equals VB.ivID
                            from TR in DB.dtPurcheses
                            .Where(o => SL.PurchaseID == o.pID)
                            .DefaultIfEmpty()
                            from SD in DB.dtStockDetails
                            .Where(o => o.StockID == SL.sID)
                            .DefaultIfEmpty()
                            where SL.SaleID == query.ID

                            select new skStock
            {
                Stockid        = SL.sID,
                Name           = SL.ItemTitle,
                Description    = SL.ItemDesc,
                purchaseddate  = TR.Purchesed_Date,
                purchasedvalue = SD.PurchaseValue,
                Sold           = SL.Sold,
                Created        = SL.Created,
                SaleValue      = SD.SaleValue,
                CategoryObject = new skCategory
                {
                    Description = ST.Description,
                    Name        = ST.Title,
                    StockTypeID = ST.CatID
                },
                ValueBandObject = new skValueBands
                {
                    Description = VB.Description,
                    HighValue   = VB.HighValue,
                    ID          = VB.ivID,
                    LowValue    = VB.LowValue,
                }
            };

            if (query == null)
            {
                throw new NoRecordException(typeof(skSales));
            }
            else
            {
                query.StockList = stocklist.ToList <skStock>();

                return(query);
            }
        }
Ejemplo n.º 4
0
        public List <ITransaction> GetTransactionList(SearchFilterObject SearchFilter)
        {
            List <ITransaction> ReturnList = new List <ITransaction>();

            StockRepo   StockRepo   = new StockRepo();
            AddressRepo AddressRepo = new AddressRepo();

            TransactionType TranType = (TransactionType)SearchFilter.ExtraSearchObject1;

            if (TranType == TransactionType.All || TranType == TransactionType.Sale)
            {
                var SalesQuery = (from S in DB.dtSales
                                  join U in DB.dtUsers on S.SoldBy equals U.uID
                                  join UD in DB.dtUserDetails on U.uID equals UD.UserID
                                  join P in DB.dtPersons on S.PersonID equals P.pID

                                  where S.tID.ToString().Equals(SearchFilter.ObjectID == null ? S.tID.ToString() : SearchFilter.ObjectID) &&
                                  S.Title.IndexOf(SearchFilter.ObjectName == null ? S.Title : SearchFilter.ObjectName) >= 0 &&
                                  S.Description.IndexOf(SearchFilter.ObjectDescription == null ? S.Description : SearchFilter.ObjectDescription) >= 0 &&
                                  (S.Created >= SearchFilter.ObjectCreatedFrom && S.Created <= SearchFilter.ObjectCreatedTo)
                                  select new skSales
                {
                    ID = S.tID,
                    Title = S.Title,
                    Description = S.Description,
                    Postage = S.PandP,
                    Amount = S.SoldValue,
                    SaleDate = S.SoldDate,
                    PayPalFees = S.PaypayFees,
                    PayPalTransactionID = S.PayPalTransactionID,
                    Created = S.Created,
                    Updated = S.Updated,
                    TransactionTime = S.SoldDate,
                    SaleMethod = S.SaleMethod,
                    UserObj = new skUser
                    {
                        UserID = U.uID,
                        DOB = UD.DateOfBirth,
                        Email = UD.Email,
                        FistName = UD.FirstName,
                        LastName = UD.LastName,
                        HomePhone = UD.HomePhone,
                        Initials = UD.Initials,
                        UserName = U.UserName,
                        WorkPhone = UD.WorkPhone
                    },
                    PersonObj = new skPerson
                    {
                        pID = P.pID,
                        Created = P.Created,
                        EbayName = P.EbayName,
                        Email = P.Email,
                        FirstName = P.FirstName,
                        HomePhone = P.HomePhone,
                        LinkedAddresses = AddressRepo.GetPersonAddressList(P.pID).ToList(),
                        Mobile = P.WorkPhone,
                        WorkPhone = P.WorkPhone,
                        Surname = P.SureName,
                        Updated = P.Updated
                    }
                    ,
                    StockList = new List <skStock>(StockRepo.GetStockListBySaleID(S.tID))
                }).Take(SearchFilter.RecordsToReturn == 0 ? 10000 : SearchFilter.RecordsToReturn);

                foreach (var item in SalesQuery)
                {
                    ReturnList.Add(item);
                }
            }
            if (TranType == TransactionType.All || TranType == TransactionType.Purchase)
            {
                var VendorRepo = new VendorRepo();

                var PurchaseQuery = (from P in DB.dtPurcheses
                                     from U in DB.dtUsers
                                     .Where(x => P.AddedBy == x.uID)
                                     .DefaultIfEmpty()
                                     where P.pID.ToString().Equals(SearchFilter.ObjectID == null ? P.pID.ToString() : SearchFilter.ObjectID) &&
                                     P.ItemTitle.IndexOf(SearchFilter.ObjectName == null ? P.ItemTitle : SearchFilter.ObjectName) >= 0 &&
                                     P.ItemDescription.IndexOf(SearchFilter.ObjectDescription == null ? P.ItemDescription : SearchFilter.ObjectDescription) >= 0 &&
                                     (P.Created >= SearchFilter.ObjectCreatedFrom && P.Created <= SearchFilter.ObjectCreatedTo)
                                     select new skPurchase
                {
                    ID = P.pID,
                    Created = P.Created,
                    CreatedBy = U.UserName,
                    PapPalTransactionID = P.PayPalTransactionID,
                    Description = P.ItemDescription,
                    Title = P.ItemTitle,
                    Invoice = P.InvoiceID,
                    Amount = Convert.ToDecimal(P.PurchesedValue),
                    Postage = Convert.ToDecimal(P.ShippingCosts),
                    VendorObject = VendorRepo.GetVendorDetails(Convert.ToInt32(P.VendorID)),
                    PurchaseDate = P.Purchesed_Date,
                    TransactionTime = P.Purchesed_Date,
                    Updated = P.Updated,
                    LinkedStock = new List <skStock>(StockRepo.GetStockListByPrucahseID(P.pID))
                }).Take(SearchFilter.RecordsToReturn == 0 ? 10000 : SearchFilter.RecordsToReturn);

                foreach (var item in PurchaseQuery)
                {
                    ReturnList.Add(item);
                }
            }

            if (TranType == TransactionType.All || TranType == TransactionType.Refund)
            {
                var RefundQuery = (from R in DB.dtRefunds
                                   from U in DB.dtUsers
                                   .Where(x => R.RefundedBy == x.uID)
                                   .DefaultIfEmpty()
                                   join UD in DB.dtUserDetails on U.uID equals UD.UserID

                                   join S in DB.dtStocks on R.StockID equals S.sID
                                   join ST in DB.dtCategories on S.CategoryID equals ST.CatID
                                   from SD in DB.dtStockDetails
                                   .Where(o => o.StockID == S.sID)
                                   .DefaultIfEmpty()

                                   select new skRefund
                {
                    Amount = R.Amount,
                    Created = R.Created,
                    Description = R.Reason,
                    Title = S.ItemTitle,
                    ID = R.rID,
                    PayPalTransactionID = R.PayPalTransactionID,
                    SHippingCosts = R.Postage,
                    StockItem = new skStock
                    {
                        Stockid = S.sID,
                        Created = S.Created,
                        Description = S.ItemDesc,
                        Name = S.ItemTitle,
                        purchasedvalue = SD.PurchaseValue,
                        SaleValue = SD.SaleValue,
                        Sold = S.Sold,
                        Updated = S.Updated,
                        CategoryObject = new skCategory
                        {
                            Description = ST.Description,
                            Name = ST.Title,
                            StockTypeID = ST.CatID
                        }
                    },
                    TransactionTime = R.Refunded,
                    TransactionType = TransactionType.Refund,
                    Updated = R.Updated,
                    User = new skUser
                    {
                        UserID = U.uID,
                        DOB = UD.DateOfBirth,
                        Email = UD.Email,
                        FistName = UD.FirstName,
                        LastName = UD.LastName,
                        HomePhone = UD.HomePhone,
                        Initials = UD.Initials,
                        UserName = U.UserName,
                        WorkPhone = UD.WorkPhone
                    }
                }).Take(SearchFilter.RecordsToReturn == 0 ? 10000 : SearchFilter.RecordsToReturn);

                foreach (var item in RefundQuery)
                {
                    ReturnList.Add(item);
                }
            }

            ReturnList = ReturnList.OrderBy(x => x.TransactionTime).Take(SearchFilter.RecordsToReturn == 0? 10000 : SearchFilter.RecordsToReturn).ToList();
            ReturnList = ReturnList.OrderBy(x => x.TransactionTime).Take(SearchFilter.RecordsToReturn == 0 ? 10000 : SearchFilter.RecordsToReturn).ToList();
            return(ReturnList);
        }