private static async Task<StatusResult<PickupCycle>> InsertPickupCycleAsync(PickupCycle cycle)
 {
     try
     {
         var db = BottleRocketDbContext.Create();
         db.PickupCycles.Add(cycle);
         await db.SaveChangesAsync();
     }
     catch (Exception ex)
     {
         return StatusResult<PickupCycle>.Error(ex.Message);
     }
     return StatusResult<PickupCycle>.Success(cycle);
 }
        //public static async Task<StatusResult<PickupReceipt>> CreatePickupReceipt(PickupReceiptBindingModel model)
        //{
        //    //TODO:: Need to verify this logic. 1. When a pickup receipt is created for the user,
        //    // we should also automatically flag the pickup as done and flag it is true

        //    // first get the schedule pickup id, since user can only have 1 pending pickup at a time
        //    var pendingPickupResult = await PickupManager.GetPendingPickupAsync(model.UserId);
        //    if (pendingPickupResult.Code != StatusCode.OK && pendingPickupResult.Result != null)
        //    {
        //        // the user doesn't have a pending pickup, so we can't create a receipt
        //        return StatusResult<PickupReceipt>.Error("User does not have a pending up pickup");
        //    }

        //    var scheduledPickup = pendingPickupResult.Result;
        //    scheduledPickup.IsPickedUp = true;

        //    // create pickupreceipt model
        //    var pickupReceipt = new PickupReceipt()
        //    {
        //        UserId = model.UserId,
        //        ScheduledPickupId = pendingPickupResult.Result.Id,

        //    }

        //NOTE:: NOT DONE
        //}


        ///// <summary>
        ///// Insert a pickup receipt asyncronously
        ///// </summary>
        ///// <param name="r">PickupReceipt object properly populated</param>
        ///// <returns>StatusResult</returns>
        //public static async Task<StatusResult<PickupReceipt>> InsertPickupReceiptAsync(PickupReceipt r)
        //{
        //    try
        //    {
        //        var db = PickupReceiptDbContext.Create();
        //        db.PickupReceipts.Add(r);
        //        await db.SaveChangesAsync();
        //    }
        //    catch (Exception ex)
        //    {
        //        return StatusResult<PickupReceipt>.Error(ex.Message);
        //    }
        //    return StatusResult<PickupReceipt>.Success();
        //}

        ///// <summary>
        ///// Insert a pickup receipt 
        ///// </summary>
        ///// <param name="r">PickupReceipt object properly populated</param>
        ///// <returns>StatusResult</returns>
        //public static StatusResult<PickupReceipt> InsertPickupReceipt(PickupReceipt r)
        //{
        //    try
        //    {
        //        var db = PickupReceiptDbContext.Create();
        //        db.PickupReceipts.Add(r);
        //        db.SaveChanges();
        //    }
        //    catch (Exception ex)
        //    {
        //        return StatusResult<PickupReceipt>.Error(ex.Message);
        //    }
        //    return StatusResult<PickupReceipt>.Success();
        //}

        #endregion

        #region Pickup Cycles

        public static async Task<StatusResult<PickupCycle>> CreatePickupCycleAsync(PickupCycleBindingModel model)
        {
            // calling create community here. This method checks if a community exist and returns an error with the existing community if found
            // else create a new community and return it
            var comResult = await BRUserManager.CreateCommunityAsync(model.CommunityName);
            if (comResult.Result == null)
            {
                throw new NullReferenceException("comResult.Result is null");
            }
            var pickupCycle = new PickupCycle()
            {
                Notes = model.Notes,
                GlassWeight = model.GlassWeight,
                AluminumWeight = model.AluminumWeight,
                StandardPlasticWeight = model.StandardPlastic,
                MiscPlasticWeight = model.MiscPlastic,
                DateCreated = DateTime.Now,
                LastUpdated = DateTime.Now,
                PickupDate = model.PickupDate,
                CommunityId = comResult.Result.Id,
                TotalBags = model.TotalBags
            };
            return await InsertPickupCycleAsync(pickupCycle);
        }