Esempio n. 1
0
        public async Task <IEnumerable <ObjectiveDTO> > GetObjectivesAsync()
        {
            StatusUpdate statusUpdate = new StatusUpdate();
            var          objectives   = await Database.Objective.GetAllAsync();

            foreach (var item in objectives)
            {
                if (statusUpdate.UpdateStatus(item))
                {
                    await Database.Objective.UpdateAsync(item);
                }
            }
            await Database.SaveAsync();

            return(mapper.Map <IEnumerable <Objective>, List <ObjectiveDTO> >(objectives));
        }
Esempio n. 2
0
        public async Task <ObjectiveDTO> GetObjectiveAsync(int?id)
        {
            if (id == null || !id.HasValue)
            {
                throw new ValidationException("Empty id", "");
            }
            var objective = await Database.Objective.GetAsync(id.Value);

            if (objective == null)
            {
                throw new ValidationException("Not found", "");
            }
            StatusUpdate statusUpdate = new StatusUpdate();

            if (statusUpdate.UpdateStatus(objective))
            {
                await Database.Objective.UpdateAsync(objective);

                await Database.SaveAsync();
            }
            return(mapper.Map <Objective, ObjectiveDTO>(objective));
        }