Example #1
0
        /// <summary>
        /// Registers a waste collection to the database context
        /// Calculates points and updates household point balance before storing
        /// </summary>
        /// <param name="collection"></param>
        /// <returns></returns>
        public async Task <WasteCollection> RegisterWasteCollectionAsync(WasteCollection collection)
        {
            RegisterPointsForCollection(collection);
            await Context.WasteCollections.AddAsync(collection);

            await Context.SaveChangesAsync();

            return(collection);
        }
        public async Task <ActionResult <Household> > CreateNewHousehold([FromBody] Household household)
        {
            household.OwnerId = HttpContext.User.GetClaim("sub").Value;
            await Context.Households.AddAsync(household);

            await Context.SaveChangesAsync();

            return(household);
        }