Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Udid,UserIdFk,Disease,DiseaseIdfk")] UserDisease userDisease)
        {
            if (id != userDisease.Udid)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(userDisease);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserDiseaseExists(userDisease.Udid))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(userDisease));
        }
        public async Task <IActionResult> Create([Bind("Udid,UserIdFk,data,Disease,DiseaseIdfk")] UserDisease userDisease)
        {
            var x = _context.UserDetails.ToList();
            var z = 0;

            foreach (var d in x)
            {
                z = d.UserId;
            }
            UserDisease obj = new UserDisease
            {
                Udid     = userDisease.Udid,
                data     = _userManager.GetUserId(HttpContext.User),
                Disease  = userDisease.Disease,
                UserIdFk = z,
            };

            if (ModelState.IsValid)
            {
                _context.Add(obj);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(userDisease));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("Udid,UserIdFk,Disease,DiseaseIdfk")] UserDisease userDisease)
        {
            if (ModelState.IsValid)
            {
                _context.Add(userDisease);
                await _context.SaveChangesAsync();

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