Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("AdultId,JuvenileId,EmailId")] MemberEmail memberEmail)
        {
            if (id != memberEmail.AdultId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(memberEmail);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MemberEmailExists(memberEmail.AdultId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AdultId"]    = new SelectList(_context.AdultMember, "Id", "FirstName", memberEmail.AdultId);
            ViewData["EmailId"]    = new SelectList(_context.Email, "Id", "Addr", memberEmail.EmailId);
            ViewData["JuvenileId"] = new SelectList(_context.JuvenileMember, "Id", "FirstName", memberEmail.JuvenileId);
            return(View(memberEmail));
        }
Beispiel #2
0
 static public bool SendEmailHandler(MemberEmail email, PrizeConstants.EmailType emailType, string emailSubject, List <string> additionalContents)
 {
     try
     {
         return(PrizeEmail.SendEmailByType(email.EmailAddress, emailType, emailSubject, additionalContents));
     }
     catch (Exception e)
     {
         PrizeLogs.SaveSystemErrorLog(email.MemberId, email.EmailId, PrizeConstants.SystemErrorLevel.LevelNormal, "Email thread", "Sending email " + email.EmailType.ToString(), e);
         return(false);
     }
 }
Beispiel #3
0
        public async Task <IActionResult> Create([Bind("AdultId,JuvenileId,EmailId")] MemberEmail memberEmail)
        {
            if (ModelState.IsValid)
            {
                _context.Add(memberEmail);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AdultId"]    = new SelectList(_context.AdultMember, "Id", "FirstName", memberEmail.AdultId);
            ViewData["EmailId"]    = new SelectList(_context.Email, "Id", "Addr", memberEmail.EmailId);
            ViewData["JuvenileId"] = new SelectList(_context.JuvenileMember, "Id", "FirstName", memberEmail.JuvenileId);
            return(View(memberEmail));
        }
Beispiel #4
0
        public async Task <IActionResult> AddMember(int id, [FromBody] MemberEmail Email)
        {
            if (Email == null || Email.Email == null)
            {
                return(BadRequest("Email body can not be null"));
            }

            Board board = await _context.Boards.FindAsync(id);

            if (board == null)
            {
                return(NotFound("No board with that ID exists"));
            }

            User ToAdd = await _userManager.FindByEmailAsync(Email.Email);

            if (ToAdd == null)
            {
                return(NotFound("No user with that email exists"));
            }

            User user = await _userManager.GetUserAsync(HttpContext.User).ConfigureAwait(false);

            if (board.Owner.Email != user.Email)
            {
                return(Forbid("Only the owner is permited to make changes"));
            }

            MemberOf MemberOf = new MemberOf
            {
                MemberID = ToAdd.Id,
                Member   = ToAdd,
                BoardId  = board.Id,
                Board    = board
            };

            board.Members.Add(MemberOf);
            await _context.SaveChangesAsync();

            return(Ok(new { Success = true }));
        }