public async Task <IActionResult> Create([Bind("groceryId,itemName,quantity,FamilyCodeName,memberId")] groceryList groceryList)
        {
            if (ModelState.IsValid)
            {
                groceryList.FamilyCodeName = User.Claims.FirstOrDefault(x => x.Type == "FamilyCodeName").Value;
                _context.Add(groceryList);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(groceryList));
        }
        public async Task <IActionResult> Create([Bind("calendarId,eventName,date,startTime,endTime,memberId")] Calendar calendar)
        {
            calendar.FamilyCodeName = User.Claims.FirstOrDefault(x => x.Type == "FamilyCodeName").Value;
            if (ModelState.IsValid)
            {
                _context.Add(calendar);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(calendar));
        }
示例#3
0
        public async Task <IActionResult> Create([Bind("memberId,firstName,lastName,nickName,FamilyCodeName")] Member member)
        {
            if (ModelState.IsValid)
            {
                member.FamilyCodeName = User.Claims.FirstOrDefault(x => x.Type == "FamilyCodeName").Value;
                //if (member.nickName.Contains("Daddy") || member.nickName.Contains("Mommy"))
                //{
                //    var IsAdminClaim = new Claim(model.IsAdmin.ToString(), "IsAdmin");
                //    var IsAdminClaim = new Claim("IsAdmin", "IsAdmin");
                //    await _userManager.AddClaimAsync(user, IsAdminClaim);
                //}

                _context.Add(member);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(member));
        }