Esempio n. 1
0
        public async Task <int> Create(SprintDTO sprint)
        {
            //Set this sprint to the current sprint
            var sprintCreate = new Entities.Sprint
            {
                SprintName = sprint.SprintName,
                StartDate  = sprint.StartDate,
                EndDate    = sprint.EndDate,
                IsCurrent  = true,
                GuildId    = sprint.GuildId,
                Tasks      = new List <Entities.Task>()
            };
            //Loop through prev sprints that are current and set them to false
            var prevCurrentSprints = _context.Sprints.Where(s => s.IsCurrent && s.GuildId == sprint.GuildId);

            foreach (var prevSprints in prevCurrentSprints)
            {
                prevSprints.IsCurrent = false;
            }

            _context.Sprints.Add(sprintCreate);
            await _context.SaveChangesAsync();

            return(sprintCreate.Id);
        }
Esempio n. 2
0
        public async System.Threading.Tasks.Task Update(SprintDTO sprint)
        {
            var sprintUpdate = await _context.Sprints.FirstOrDefaultAsync(s => s.Id == sprint.Id);

            if (sprintUpdate == null)
            {
                return;
            }

            sprintUpdate.SprintName = sprint.SprintName;
            sprintUpdate.StartDate  = sprint.StartDate;
            sprintUpdate.EndDate    = sprint.EndDate;
            sprintUpdate.IsCurrent  = sprint.IsCurrent;
            sprintUpdate.GuildId    = sprint.GuildId;
            await _context.SaveChangesAsync();
        }
Esempio n. 3
0
        public async Task <SprintDTO> Current(ulong guildId)
        {
            var sprint = await _context.Sprints.Include(s => s.Tasks)
                         .FirstOrDefaultAsync(s => s.IsCurrent && s.GuildId == guildId);

            if (sprint == null)
            {
                return(null);
            }
            var sprintReturn = new SprintDTO
            {
                Id         = sprint.Id,
                SprintName = sprint.SprintName,
                IsCurrent  = sprint.IsCurrent,
                StartDate  = sprint.StartDate,
                EndDate    = sprint.EndDate,
                GuildId    = sprint.GuildId,
                Tasks      = sprint.Tasks == null ? new List <int>() : sprint.Tasks.Select(us => us.Id).ToList()
            };

            return(sprintReturn);
        }