Esempio n. 1
0
        private async Task <IEnumerable <Milestone> > GetMilestonesAsync(IDbConnection connection, int projectId, IEnumerable <DateTime> dates)
        {
            var prj = await connection.FindAsync <Project>(projectId);

            List <Milestone> results = new List <Milestone>();

            foreach (var date in dates)
            {
                var ms =
                    await connection.FindWhereAsync <Milestone>(new { OrganizationId = OrgId, Date = date }) ??
                    new Milestone(date)
                {
                    OrganizationId = OrgId
                };

                await Milestone.EnsureUniqueNameAsync(connection, ms);

                if (ms.Id == 0)
                {
                    await connection.SaveAsync(ms, CurrentUser);
                }

                results.Add(ms);
            }

            return(results);
        }
Esempio n. 2
0
            public async Task <int> GetMilestoneIdAsync(IDbConnection cn, IUser currentUser, int orgId, int teamId)
            {
                var date = GetDate();
                var ms   =
                    await cn.FindWhereAsync <Milestone>(new { OrganizationId = orgId, TeamId = teamId, Date = date }, method : FindWhereMethod.First) ??
                    await cn.FindWhereAsync <Milestone>(new { OrganizationId = orgId, Date = date }, method : FindWhereMethod.First);

                if (ms == null)
                {
                    ms = new Milestone(date)
                    {
                        OrganizationId = orgId
                    };
                    await Milestone.EnsureUniqueNameAsync(cn, ms);

                    await cn.SaveAsync(ms, currentUser);
                }

                return(ms.Id);
            }