public async Task <IActionResult> Create([Bind("DonorID,LastName,FirstName,PESEL,BloodType")] Donor donor)
        {
            if (ModelState.IsValid)
            {
                _context.Add(donor);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(donor));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("HospitalID,Name,Address")] Hospital hospital)
        {
            if (ModelState.IsValid)
            {
                _context.Add(hospital);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(hospital));
        }
        public async Task <IActionResult> Create([Bind("BloodDonationID,DonationDate,Volume,NurseID,DonorID")] BloodDonation bloodDonation)
        {
            if (ModelState.IsValid)
            {
                _context.Add(bloodDonation);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DonorID"] = new SelectList(_context.Donors, "DonorID", "FullName", bloodDonation.DonorID);
            ViewData["NurseID"] = new SelectList(_context.Nurses, "NurseID", "FullName", bloodDonation.NurseID);
            return(View(bloodDonation));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("NodeId,Name,UserId,IsParent,ParentId,AddTime")] Node node)
        {
            if (!UserManager.GetUserName(User).ToLower().Equals("admin"))
            {
                return(RedirectToAction(nameof(HomeController.Index), "Home"));
            }
            if (ModelState.IsValid)
            {
                node.AddTime = DateTime.Now;
                if (node.IsParent == IsParent.Parent)
                {
                    node.ParentId = string.Empty;
                }
                _context.Add(node);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewBag.UserId   = new SelectList(_context.Users, "Id", "UserName", node.UserId);
            ViewBag.ParentId = new SelectList(_context.Nodes.Where(a => a.IsParent == IsParent.Parent), "NodeId", "Name", node.ParentId);
            return(View(node));
        }
        public async Task <IActionResult> Create([Bind(",LastName,FirstName,PESEL,HireDate,HospitalID")] Nurse nurse)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(nurse);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                ViewData["HospitalID"] = new SelectList(_context.Hospitals, "HospitalID", "Name", nurse.HospitalID);
            }
            catch (DbUpdateException /* ex */)
            {
                //Log the error (uncomment ex variable name and write a log.
                ModelState.AddModelError("", "Unable to save changes. " +
                                         "Try again, and if the problem persists " +
                                         "see your system administrator.");
            }
            return(View(nurse));
        }