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 Task <int> Create(TaskDTO task)
        {
            var TaskCreate = new Entities.Task
            {
                TaskName      = task.TaskName,
                SprintId      = task.SprintId,
                StartTime     = task.StartTime,
                EndTime       = task.EndTime,
                DiscordRoleId = task.DiscordRoleId
            };
            await _context.Tasks.AddAsync(TaskCreate);

            await _context.SaveChangesAsync();

            return(TaskCreate.Id);
        }
Esempio n. 3
0
        public async Task <(Status status, ReminderDTO reminder)> Create(ReminderDTO reminder)
        {
            var existingReminder = await Get(reminder.StartTime, reminder.GuildId, reminder.Summary);

            if (existingReminder.status == Status.Found)
            {
                return(Status.Conflict, existingReminder.reminder);
            }

            var reminderCreate = new Entities.Reminder
            {
                StartTime = reminder.StartTime,
                GuildId   = reminder.GuildId,
                Summary   = reminder.Summary,
                Reminded  = reminder.Reminded
            };
            var createdReminder = await _context.Reminders.AddAsync(reminderCreate);

            await _context.SaveChangesAsync();

            if (createdReminder.Entity == null)
            {
                return(Status.Error, null);
            }

            return(Status.Created, new ReminderDTO
            {
                StartTime = createdReminder.Entity.StartTime,
                GuildId = createdReminder.Entity.GuildId,
                Summary = createdReminder.Entity.Summary,
                Reminded = createdReminder.Entity.Reminded
            });
        }