public Task <List <BillingTransaction> > List(BillingTransactionSearchParams searchParams)
        {
            var taskResult = Task.Run(() =>
            {
                using (var context = new DbContext())
                {
                    var ctx = context
                              .BillingTransactions
                              .Include(s => s.Flat)
                              .Include(s => s.Society);

                    if (searchParams.SocietyId.HasValue)
                    {
                        ctx = ctx
                              .Where(t => t.SocietyId == searchParams.SocietyId.Value);
                    }

                    if (searchParams.Year.HasValue)
                    {
                        ctx = ctx
                              .Where(t => t.Date.Year == searchParams.Year.Value);
                    }

                    if (searchParams.Month.HasValue)
                    {
                        ctx = ctx
                              .Where(t => t.Date.Month == searchParams.Month.Value);
                    }

                    return(ctx.ToList());
                }
            });

            return(taskResult);
        }
        public Task <List <BillingTransaction> > MyHistory(BillingTransactionSearchParams searchParams)
        {
            var taskResult = Task.Run(() =>
            {
                using (var context = new DbContext())
                {
                    var ctx = (from msf in context.MapsSocietiesToFacilities
                               join f in context.Facilities on msf.FacilityId equals f.Id
                               join flr in context.Floors on f.Id equals flr.FacilityId
                               join fls in context.Flats on flr.Id equals fls.FloorId
                               join mffo in context.MapsFlatToFlatOwner on fls.Id equals mffo.FlatId
                               join fo in context.FlatOwners on mffo.FlatOwnerId equals fo.Id
                               join bt in context.BillingTransactions on fls.Id equals bt.FlatId
                               where msf.SocietyId == searchParams.SocietyId.Value && fo.MobileNo == searchParams.Username
                               select bt)
                              .Include(s => s.Flat)
                              .Include(s => s.Society);

                    return(ctx.ToList());
                }
            });

            return(taskResult);
        }
Example #3
0
 public Task <List <BillingTransaction> > MyHistory(BillingTransactionSearchParams searchParams)
 {
     return(_billingTransactionRepository.MyHistory(searchParams));
 }