Ejemplo n.º 1
0
        public async Task <IActionResult> CreateBaptism(BaptismCreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                var baptism = new Baptism(model);
                foreach (var id in model.SelectedMembers)
                {
                    var member = await memberRepository.GetMember(id);

                    if (member != null)
                    {
                        try
                        {
                            baptism.AddMember(member);
                        }
                        catch (Exception ex)
                        {
                            throw new Exception("Erro ao adicionar membros presentes.", ex);
                        }
                    }
                }
                try
                {
                    repository.Add(baptism);
                }
                catch (Exception ex)
                {
                    throw new Exception("Erro ao salvar Escola Dominical", ex);
                }

                return(RedirectToAction("list", "event"));
            }
            return(await ReloadDataAndReturnView());
        }
Ejemplo n.º 2
0
 public Baptism(BaptismCreateViewModel model)
 {
     Date       = model.Date;
     Place      = model.Place;
     BaptizerId = model.TeacherId;
     EventType  = EventType.BATISMO;
     Baptizeds  = new HashSet <OccasionMember>();
 }