Exemple #1
0
        public ResultDto UpdateDayNames(List <DayDto> dayDtos, string userId)
        {
            dayDtos.ForEach(d =>
            {
                var origDay = _context.Days.Where(day => day.UUID == d.UUID && day.User.UUID == userId).FirstOrDefault();
                if (origDay != null)
                {
                    origDay.Name = d.Name;
                    _context.Entry(origDay).State = EntityState.Modified;
                    _context.SaveChanges();
                }
            });

            return(new ResultDto(true, "Day names updated"));
        }
Exemple #2
0
        public ResultDto DeleteMultipleSharedMeals(List <string> mealIds, string userId)
        {
            mealIds.ForEach(mealId => {
                var sharedMeal = _context.SharedMeals.Where(sm => sm.UUID == mealId && sm.User.UUID == userId).FirstOrDefault();

                if (sharedMeal == null)
                {
                    _logger.LogDebug("SharedMeal not found with UUID: ", mealId);
                }

                _context.SharedMeals.Remove(sharedMeal);
                _context.SaveChanges();
            });

            return(new ResultDto(true, "Meals deleted succesfully"));
        }
Exemple #3
0
        public ResultDto DeleteMultipleUsers(List <string> userIds)
        {
            userIds.ForEach(id =>
            {
                var user = _context.Users.Where(u => u.UUID == id).FirstOrDefault();
                if (user != null)
                {
                    _context.Meals.RemoveRange(_context.Meals.Where(m => m.User == user));
                    _context.Users.Remove(user);
                    _context.SaveChanges();
                }
            });

            return(new ResultDto(true, "Days deleted succesfully"));
        }
Exemple #4
0
        public ResultDto DeleteMultipleLikes(List <string> likeIds, string userId)
        {
            likeIds.ForEach(likeId => {
                var like = _context.Likes.Where(l => l.User.UUID == userId && l.UUID == likeId).FirstOrDefault();

                if (like == null)
                {
                    _logger.LogDebug("Like not found with id: " + likeId + " and with userId " + userId);
                }

                _context.Likes.Remove(like);
                _context.SaveChanges();
            });
            return(new ResultDto(true, "Likes deleted succesfully"));
        }
Exemple #5
0
        public ResultDto DeleteMultipleFoods(List <string> foodIds, string userId)
        {
            foodIds.ForEach(foodId => {
                var food = _context.Foods.Include(f => f.User).Where(f => f.UUID == foodId && f.User.UUID == userId).FirstOrDefault();

                if (food == null)
                {
                    _logger.LogDebug("Food not found with id: ", foodId);
                }

                _context.Foods.Remove(food);
                _context.SaveChanges();
            });

            return(new ResultDto(true, "Foods deleted succesfully"));
        }
Exemple #6
0
        public ResultDto DeleteMultipleTrackedPeriod(List <string> trackedPeriodIds, string userId)
        {
            trackedPeriodIds.ForEach(id =>
            {
                var trackedPeriod = _context.TrackedPeriods.Where(tp => tp.UUID == id && tp.User.UUID == userId)
                                    .FirstOrDefault();

                if (trackedPeriod == null)
                {
                    _logger.LogDebug("TrackedPeriod not found with UUID: ", id);
                }

                _context.TrackedPeriods.Remove(trackedPeriod);
                _context.SaveChanges();
            });

            return(new ResultDto(true, "Tracked period deleted succesfully"));
        }