Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("Id, Name, ConcurrencyStamp, NormalizedName")] AspNetRoles aspNetRoles)
        {
            if ((aspNetRoles.Name + "").Trim() == "")
            {
                ModelState.AddModelError("", "No role to add");
                TempData["Message"] = "Role name cannot be null, empty, or blanks";
                return(RedirectToAction(nameof(Index)));
            }

            var dup = _context.AspNetRoles.Where(w => w.Name == aspNetRoles.Name).FirstOrDefault();

            if (dup != null)
            {
                ModelState.AddModelError("", "duplication");
                TempData["Message"] = "Role name [" + aspNetRoles.Name + "] is already on file";
                return(RedirectToAction(nameof(Index)));
            }

            try
            {
                var roleList = await _context
                               .AspNetRoles
                               .OrderBy(m => m.Id)
                               .LastOrDefaultAsync();

                int roleId = int.Parse(roleList.Id) + 1;
                aspNetRoles.Id             = roleId.ToString();
                aspNetRoles.Name           = aspNetRoles.Name.Trim();
                aspNetRoles.NormalizedName = aspNetRoles.Name.ToUpper();

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

                    TempData["Message"] = "role added: " + aspNetRoles.Name;
                    return(RedirectToAction(nameof(Index)));
                }
            }
            catch (Exception ex)
            {
                //   throw;
                ModelState.AddModelError("", ex.GetBaseException().Message);
                TempData["Message"] = "Failed add role: " + aspNetRoles.Name;
                //return View(aspNetRoles);
                return(View(nameof(Index)));
            }
            return(View(nameof(Index)));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("PatientTreatmentId,TreatmentId,DatePrescribed,Comments,PatientDiagnosisId")] PatientTreatment patientTreatment)
        {
            int DID = getDID();

            if (getDID() < 0)
            {
                ModelState.AddModelError("DiagnosId", "No Diagnos to create.");
                return(RedirectToAction("Index", "HKPatientDiagnosis"));
            }

            patientTreatment.PatientDiagnosisId = (int)HttpContext.Session.GetInt32("PDID");

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

                    TempData["Message"] = $"New record is created.";
                    return(RedirectToAction(nameof(Index)));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.GetBaseException().Message);
            }

            ViewData["PatientDiagnosisId"] = new SelectList(_context.PatientDiagnosis, "PatientDiagnosisId", "PatientDiagnosisId", patientTreatment.PatientDiagnosisId);
            ViewData["TreatmentId"]        = new SelectList(_context.Treatment.Where(b => b.DiagnosisId == DID).OrderBy(a => a.Name), "TreatmentId", "Name");

            return(View(patientTreatment));
        }
        public async Task <IActionResult> Create([Bind("MedicationTypeId,Name")] MedicationType medicationType)
        {
            if (ModelState.IsValid)
            {
                _context.Add(medicationType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(medicationType));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("ConcentrationCode")] ConcentrationUnit concentrationUnit)
        {
            if (ModelState.IsValid)
            {
                _context.Add(concentrationUnit);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(concentrationUnit));
        }
        public async Task <IActionResult> Create([Bind("DispensingCode")] DispensingUnit dispensingUnit)
        {
            if (ModelState.IsValid)
            {
                _context.Add(dispensingUnit);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(dispensingUnit));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("Id,Name")] DiagnosisCategory diagnosisCategory)
        {
            if (ModelState.IsValid)
            {
                _context.Add(diagnosisCategory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(diagnosisCategory));
        }
        public async Task <IActionResult> Create([Bind("CountryCode,Name,PostalPattern,PhonePattern,FederalSalesTax")] Country country)
        {
            if (ModelState.IsValid)
            {
                _context.Add(country);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(country));
        }
Exemplo n.º 8
0
        public async Task <IActionResult> Create([Bind("Fullname,PatientId,FirstName,LastName,Address,City,ProvinceCode,PostalCode,Ohip,DateOfBirth,Deceased,DateOfDeath,HomePhone,Gender")] Patient patient)
        {
            if (ModelState.IsValid)
            {
                _context.Add(patient);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProvinceCode"] = new SelectList(_context.Province, "ProvinceCode", "ProvinceCode", patient.ProvinceCode);
            return(View(patient));
        }
Exemplo n.º 9
0
        public async Task <IActionResult> Create([Bind("Din,Name,Image,MedicationTypeId,DispensingCode,Concentration,ConcentrationCode")] Medication medication)
        {
            if (medication.Concentration > 0)
            {
                if (ModelState.IsValid)
                {
                    try
                    {
                        var duplicate = from aMedi in _context.Medication
                                        where (aMedi.Din == medication.Din ||
                                               (aMedi.Name == medication.Name &&
                                                aMedi.Concentration == medication.Concentration &&
                                                aMedi.ConcentrationCode == medication.ConcentrationCode))
                                        select aMedi;

                        if (duplicate.Any())
                        {
                            TempData["Message"] = "Same data already exists.";
                        }
                        else
                        {
                            _context.Add(medication);
                            await _context.SaveChangesAsync();


                            return(RedirectToAction("Index", "HKMedications"));

                            //return RedirectToAction(nameof(Index));
                        }
                    }
                    catch (Exception ex)
                    {
                        TempData["Message"] = ex.Message;
                        return(View(medication));
                    }
                }
            }
            else
            {
                TempData["Message"] = "Concentration must be greater than 0.";
            }

            ViewData["ConcentrationCode"] = new SelectList(_context.ConcentrationUnit.OrderBy(a => a.ConcentrationCode), "ConcentrationCode", "ConcentrationCode", medication.ConcentrationCode);
            ViewData["DispensingCode"]    = new SelectList(_context.DispensingUnit.OrderBy(a => a.DispensingCode), "DispensingCode", "DispensingCode", medication.DispensingCode);

            return(View(medication));
        }
        public async Task <IActionResult> Create([Bind("PatientDiagnosisId,PatientId,DiagnosisId,Comments")] PatientDiagnosis patientDiagnosis)
        {
            string PID = HttpContext.Session.GetInt32("PID").ToString();

            if (string.IsNullOrEmpty(PID))
            {
                ModelState.AddModelError("PatientId", "No patient to create.");
                return(RedirectToAction("Index", "HKPatients"));
            }
            patientDiagnosis.PatientId = Convert.ToInt32(PID);
            if (ModelState.IsValid)
            {
                _context.Add(patientDiagnosis);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DiagnosisId"] = new SelectList(_context.Diagnosis, "DiagnosisId", "Name", patientDiagnosis.DiagnosisId);
            ViewData["PatientId"]   = new SelectList(_context.Patient, "PatientId", "FirstName", patientDiagnosis.PatientId);
            return(View(patientDiagnosis));
        }
Exemplo n.º 11
0
        public async Task <IActionResult> Create([Bind("Fullname,PatientId,FirstName,LastName,Address,City,ProvinceCode,PostalCode,Ohip,DateOfBirth,Deceased,DateOfDeath,HomePhone,Gender")] Patient patient)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(patient);
                    await _context.SaveChangesAsync();

                    TempData["Message"] = "Successfully created!!";
                    return(RedirectToAction(nameof(Index)));
                }
            }
            catch (Exception ex)
            {
                //   throw;
                ModelState.AddModelError("", ex.GetBaseException().Message);
                return(View(patient));
            }
            ViewData["ProvinceCode"] = new SelectList(_context.Province, "ProvinceCode", "ProvinceCode", patient.ProvinceCode);
            return(View(patient));
        }