public async Task <IActionResult> Edit(int id, [Bind("id,programDate,Conduct,Preside,Sacrament")] MeetingProgram meetingProgram)
        {
            if (id != meetingProgram.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(meetingProgram);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MeetingProgramExists(meetingProgram.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(meetingProgram));
        }
        public async Task <IActionResult> Create([Bind("id,programDate,Conduct,Preside,Sacrament")] MeetingProgram meetingProgram)
        {
            if (ModelState.IsValid)
            {
                _context.Add(meetingProgram);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(meetingProgram));
        }
예제 #3
0
        public IActionResult Update(string id, MeetingProgram programIn)
        {
            var program = _programService.Get(id);

            if (program == null)
            {
                return(NotFound());
            }

            _programService.Update(id, programIn);

            return(NoContent());
        }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            MeetingProgram = await _context.MeetingProgram.FirstOrDefaultAsync(m => m.ID == id);

            if (MeetingProgram == null)
            {
                return(NotFound());
            }
            return(Page());
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            MeetingProgram = await _context.MeetingProgram.FindAsync(id);

            if (MeetingProgram != null)
            {
                _context.MeetingProgram.Remove(MeetingProgram);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
예제 #6
0
        public static void Initialize(SacramentContext context)
        {
            //check for programs
            if (context.Programs.Any())
            {
                return;
            }

            var programs = new MeetingProgram[]
            {
                new MeetingProgram {
                    programDate = DateTime.Parse("2016-09-01"), Conduct = "Br. Worthington", Preside = "Bishop Christensen", Sacrament = true
                }
            };

            foreach (MeetingProgram m in programs)
            {
                context.Programs.Add(m);
            }
            context.SaveChanges();

            var hymns = new Hymn[]
            {
                new Hymn {
                    MeetingProgramID = 1, hymnNumber = 20, name = "Come, Come Ye Saints", location = HymnLocation.Opening
                },
                new Hymn {
                    MeetingProgramID = 1, hymnNumber = 175, name = "O God, The Eternal Father", location = HymnLocation.Sacrament
                },
                new Hymn {
                    MeetingProgramID = 1, hymnNumber = 81, name = "Press Forward, Saints", location = HymnLocation.Intermediate
                },
                new Hymn {
                    MeetingProgramID = 1, hymnNumber = 2, name = "The Spirit of God", location = HymnLocation.Closing
                }
            };

            foreach (Hymn h in hymns)
            {
                context.Hymns.Add(h);
            }
            context.SaveChanges();

            var talks = new Talk[]
            {
                new Talk {
                    MeetingProgramID = 1, speaker = "Gordon Smith", topic = "Baptism", Reading = "Mosiah 18:8-10", order = 1
                },
                new Talk {
                    MeetingProgramID = 1, speaker = "Jennifer Smith", topic = "The Gift of the Holy Ghost", Reading = "Moroni 10:3-5", order = 2
                },
                new Talk {
                    MeetingProgramID = 1, speaker = "Doug Smith", topic = "Endure to the End", Reading = "2 Nephi 31:19-21", order = 3
                }
            };

            foreach (Talk t in talks)
            {
                context.Talks.Add(t);
            }
            context.SaveChanges();

            var prayers = new Prayer[]
            {
                new Prayer {
                    MeetingProgramID = 1, speaker = "Celeste Smith", location = PrayerLocation.Invocation
                },
                new Prayer {
                    MeetingProgramID = 1, speaker = "Vernon Smith", location = PrayerLocation.Benediction
                }
            };

            foreach (Prayer p in prayers)
            {
                context.Prayers.Add(p);
            }
            context.SaveChanges();
        }
예제 #7
0
        public ActionResult <MeetingProgram> Create(MeetingProgram program)
        {
            _programService.Create(program);

            return(CreatedAtRoute("GetProgram", new { id = program.Id.ToString() }, program));
        }
 public void Remove(MeetingProgram programIn) =>
 _programs.DeleteOne(program => program.Id == programIn.Id);
 public void Update(string id, MeetingProgram programIn) =>
 _programs.ReplaceOne(program => program.Id == id, programIn);
 public MeetingProgram Create(MeetingProgram program)
 {
     _programs.InsertOne(program);
     return(program);
 }