예제 #1
0
        public async Task <ActionResult <IEnumerable <GenericChore> > > GetGenericChores()
        {
            var x = _genericChoresService.GetAll().ToList().Count();

            if (x == 0)
            {
                var a = new GenericChore
                {
                    Id          = Guid.Parse("4d84fb9e-14f8-40a5-8ab8-2a62c172ab22"),
                    Description = "Limpiar filtros",
                    Duration    = TimeSpan.Zero,
                    ChoreTypeId = Guid.Parse("137d2d2c-f24c-40fd-842e-e055ef9433d7"),

                    CategoryId = Guid.Parse("7bd26acc-8e68-45e6-bc9d-17ef00e69f4a"),
                };

                var b = new GenericChore
                {
                    Id          = Guid.Parse("19b0720a-aba5-4566-bd2e-53dcf08baa08"),
                    Description = "Limpieza general",
                    Duration    = TimeSpan.Zero,
                    ChoreTypeId = Guid.Parse("d522d22b-641c-4d8c-bf36-b30343d9955d"),

                    CategoryId = Guid.Parse("a1537944-006c-4144-974a-3aaf9719518e"),
                };
                _genericChoresService.Add(a);
                _genericChoresService.Add(b);
            }

            return(await _genericChoresService.GetAll().ToListAsync());
        }
예제 #2
0
 public async Task <ActionResult <GenericChore> > PostGenericChore(GenericChore genericTask)
 {
     return(await Task.Run(() =>
     {
         var output = _genericChoresService.Add(genericTask);
         return new ActionResult <GenericChore>(output);
     }));
 }
예제 #3
0
        private ElementResponse AddElementChores(Element element, int year)
        {
            var elementGenericChores = element.ElementGenericChores;

            ElementResponse ElementResponse = new ElementResponse();

            ElementResponse.Chores      = new List <ChoreResponse>();
            ElementResponse.TotalChores = 0;

            List <Chore> AllChoresElement = new List <Chore>();


            foreach (ElementGenericChore elemenGChore in elementGenericChores)
            {
                NewChoresGuideline newChoresGuideline = new NewChoresGuideline();
                newChoresGuideline.GenericChore = elemenGChore.GenericChore;
                newChoresGuideline.ElementId    = element.Id;

                GenericChore gChore       = elemenGChore.GenericChore;
                Period       gChorePeriod = gChore.Period;

                Chore LastChore = GetLastChore(element.Id, gChore.Id, year);

                if (LastChore == null)
                {
                    newChoresGuideline.TimeSpanToAddChores = GetDefaultTimeSpan(year);
                }
                else if (IsTimeSpanIncomplete(LastChore, year) == true)
                {
                    newChoresGuideline.TimeSpanToAddChores = ResumeTimeSpan(LastChore);
                }
                else
                {
                    continue;
                }

                List <Chore> choresAdded = AddingElements(newChoresGuideline);

                AllChoresElement.AddRange(choresAdded);

                ChoreResponse choreResponse = new ChoreResponse();
                choreResponse.TotalChores = choresAdded.Count();
                choreResponse.Period      = newChoresGuideline.GenericChore.Period;

                ElementResponse.Chores.Add(choreResponse);
                ElementResponse.TotalChores += choreResponse.TotalChores;
            }

            InsertChoresToDatabase(AllChoresElement);
            _formatsService.AddFormatValuesToChores(AllChoresElement);

            return(ElementResponse);
        }