Beispiel #1
0
        public IActionResult Post(string keyParoisse, string keyClocher)
        {
            Clocher clocher = _db.Clochers.Include(c => c.Paroisse).Include(c => c.Celebrations).Include(c => c.Permanences).FirstOrDefault(x => x.Key == keyClocher && x.Paroisse.Key == keyParoisse);

            ViewBag.roles = FindRole(clocher.ParoisseId).Result;
            return(View(clocher));
        }
Beispiel #2
0
        public async Task <IActionResult> Post([FromForm] AddCelebrationViewModel celebration)
        {
            //if (!ModelState.IsValid)
            //{
            //	return BadRequest(ModelState);
            //}
            await _db.Celebrations.AddAsync(celebration.Celebration);

            await _db.SaveChangesAsync();

            Clocher clocher = await _db.Clochers.Where(x => x.Id == celebration.ClocherId).FirstAsync();

            ViewBag.roles = await FindRole(clocher.ParoisseId);

            List <Celebration> l_celebration = new List <Celebration>();

            if (celebration.single_clocher)
            {
                l_celebration = await _db.Celebrations.Include("Clocher").Where(x => x.ClocherId == celebration.ClocherId).Where(x => x.Date >= DateTime.Now.AddDays(-7)).OrderBy(x => x.Date).ToListAsync();
            }
            else
            {
                l_celebration = await _db.Celebrations.Include("Clocher").Where(x => x.Clocher.ParoisseId == clocher.ParoisseId).Where(x => x.Date >= DateTime.Now.AddDays(-7)).OrderBy(x => x.Date).ToListAsync();
            }
            return(PartialView("_indexCelebrations", l_celebration));
        }
Beispiel #3
0
        public async Task <IActionResult> Edit(string keyParoisse, string keyClocher)
        {
            Clocher     clocher = _db.Clochers.Include(c => c.Paroisse).Include(c => c.Permanences).FirstOrDefault(x => x.Key == keyClocher && x.Paroisse.Key == keyParoisse);
            List <role> myRoles = await FindRole(clocher.ParoisseId);

            if (myRoles.Contains(role.Administrateur))
            {
                ViewBag.roles = myRoles;
                return(View(clocher));
            }
            return(View("notAllowed"));
        }
Beispiel #4
0
        public IActionResult Create(Clocher new_clocher)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            _db.Clochers.Add(new_clocher);
            _db.SaveChanges();

            return(RedirectToAction("Post", "Clocher", new { key = new_clocher.Key }));
        }
        public async Task <IActionResult> Post([FromForm] AddBaptemeViewModel new_bapteme)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }


            Adresse new_adress = new Adresse()
            {
                Numero       = new_bapteme.Numero,
                Rue          = new_bapteme.Rue,
                TelephoneFix = new_bapteme.TelephoneFix,
                CP           = new_bapteme.CP,
                Ville        = new_bapteme.Ville,
                Complement   = new_bapteme.Complement,
            };
            await _db.AddAsync(new_adress);

            ApplicationUser new_user = new ApplicationUser()
            {
                FirstName       = new_bapteme.FirstName,
                LastName        = new_bapteme.LastName,
                BirthDate       = new_bapteme.BirthDate,
                UserName        = Guid.NewGuid().ToString(),
                CelebrationId   = new_bapteme.CelebrationId,
                TelephoneMobile = new_bapteme.TelephoneMobile,
                Email           = new_bapteme.Email,
                IdAdress        = new_adress.Id
            };
            await _userManager.CreateAsync(new_user);

            Celebration celebration = await _db.Celebrations.FindAsync(new_bapteme.CelebrationId);

            Clocher clocher = await _db.Clochers.Where(x => x.Id == celebration.ClocherId).FirstAsync();

            UserParoisse uParoisse = new UserParoisse()
            {
                UserId = new_user.Id, ParoisseId = clocher.ParoisseId, Role = role.Contact
            };
            await _db.AddAsync(uParoisse);

            await _db.SaveChangesAsync();

            return(Ok(new_user.Id));
        }