Beispiel #1
0
        public async Task UpsertGoalsService(List <GoalModel> goals)
        {
            try
            {
                if (goals == null)
                {
                    throw new ArgumentException("Goals not entered");
                }

                List <Goal> dbGoals = new List <Goal>();

                foreach (var goal in goals)
                {
                    if (goal.UserId <= 0)
                    {
                        throw new Exception("Goals not found");
                    }
                    dbGoals.Add(Mapper.GoalsMapper.CoreToDbGoalEntity(goal));
                }

                await _goalsRepository.UpsertGoals(dbGoals);
            }
            catch (ArgumentException ae)
            {
                throw new ArgumentException(ae.Message);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }