Example #1
0
        public static async Task UpdateCommitment(this AppDbContext db, CommitmentModel model)
        {
            if (await model.Validate(db))
            {
                var commitment = await db.Commitments.FindAsync(model.id);

                commitment.Category.Id = model.category.id;
                await db.SaveChangesAsync();
            }
        }
Example #2
0
        public static async Task AddCommitment(this AppDbContext db, CommitmentModel model)
        {
            if (await model.Validate(db))
            {
                var commitment = new Commitment
                {
                    Id         = model.id,
                    Location   = model.location,
                    Subject    = model.subject,
                    Body       = model.body,
                    StartDate  = model.startDate,
                    EndDate    = model.endDate,
                    CategoryId = model.category.id
                };

                await db.Commitments.AddAsync(commitment);

                await db.SaveChangesAsync();
            }
        }