public ActionResult GetBiodata(int _id) { ActionResponse response = new ActionResponse { }; try { TblBiodata subject = biodata.GetById(_id); subject.TblLabTests = null; subject._genderName = subject.GenderNavigation.Gender; subject.GenderNavigation = null; subject._dob = Utils.Utils.toShortdate(subject.Dateofbirth); response.IsSuccessful = true; response.Message = "n/a"; response.JSONData = JsonConvert.SerializeObject(subject, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); } catch (Exception ex) { response.IsSuccessful = false; response.Message = "n/a"; } return(Json(response, new JsonSerializerSettings())); }
public IActionResult Create(int?id) { if (id == null) { return(NotFound()); } var token = HttpContext.Session.GetString("biodata_details_token"); if (string.IsNullOrEmpty(token)) { return(RedirectToAction(nameof(Index), "Biodata")); } TblBiodata _Biodata = biodata.GetById(id); LabTestDetailsViewModel _labTest = new LabTestDetailsViewModel(_Biodata, methods, specimen); ViewData["Results"] = results; ViewData["Method"] = new SelectList(methods.GetAll(), "Id", "Methodname"); /* ViewData["Biodata"] = new SelectList(_context.TblBiodata, "Id", "Fullname"); * ViewData["Method"] = new SelectList(_context.TlkpTestMethods, "Id", "InsertBy");*/ return(View(_labTest)); }
public async Task <IActionResult> Edit(int id, LabTestDetailsViewModel test) { if (id != test.LabTest.Id) { return(NotFound()); } var errors = ModelState.Values; foreach (var e in errors) { if (e.ValidationState == Microsoft.AspNetCore.Mvc.ModelBinding.ModelValidationState.Invalid) { ; } } if (ModelState.IsValid) { try { test.LabTest.UpdateBy = User.Identity.Name; tests.Update(test); /*_context.Update(tblLabTests); * await _context.SaveChangesAsync();*/ } catch (DbUpdateConcurrencyException) { if (!TblLabTestsExists(test.LabTest.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["Results"] = results; ViewData["Method"] = new SelectList(methods.GetAll(), "Id", "Methodname"); TblBiodata _Biodata = biodata.GetById(test.BioData.Id); test.BioData = _Biodata; return(View(test)); }
public void Create(TblBiodata obj) { //throw new NotImplementedException(); //obj.InsertBy= //obj.UpdateBy = admin; Context.TblBiodata.Add(obj); //obj.InsertTime = //obj.UpdateTime = DateTime.Now; Save(obj); }
public async Task <IActionResult> Create(LabTestDetailsViewModel _labTest)//[Bind("Id,Biodata,Method,Interpretation,TestingDate,TestingTime,ReportingDate,ReportingTime,InsertTime,InsertBy,UpdateTime,UpdateBy")] TblLabTests tblLabTests) { //var errors = ModelState.Values; //foreach (var e in errors) //{ // if (e.ValidationState == Microsoft.AspNetCore.Mvc.ModelBinding.ModelValidationState.Invalid) // ; //} if (ModelState.IsValid) { _labTest.LabTest.TblLabTestsIndicatorsValues = _labTest.Indicators; _labTest.LabTest.TblLabTestsSpecimen = _labTest.Specimen; _labTest.LabTest.InsertBy = _labTest.LabTest.UpdateBy = User.Identity.Name; tests.Create(_labTest); //_context.Add(tblLabTests); //await _context.SaveChangesAsync(); HttpContext.Session.SetString("biodata_details_token", ""); return(RedirectToAction(nameof(Index))); } ViewData["Results"] = results; ViewData["Method"] = new SelectList(methods.GetAll(), "Id", "Methodname", _labTest.LabTest.Method); /*ViewData["Biodata"] = new SelectList(_context.TblBiodata, "Id", "Fullname", tblLabTests.Biodata); * ViewData["Method"] = new SelectList(_context.TlkpTestMethods, "Id", "InsertBy", tblLabTests.Method);*/ TblBiodata _Biodata = biodata.GetById(_labTest.BioData.Id); _labTest.BioData = _Biodata; var _indicators = indicators.GetAll(); foreach (var i in _labTest.Indicators) { i.IndicatorName = _indicators.FirstOrDefault(x => x.Id == i.Indicator).IndicatorName; } //_labTest.Indicators = return(View(_labTest)); }
public void Update(TblBiodata obj) { //throw new NotImplementedException(); TblBiodata subject = GetById(obj.Id); if (subject != null) { subject.Fullname = obj.Fullname; subject.LegalGardianName = obj.LegalGardianName; subject.Dateofbirth = DateTime.Parse(obj.Dateofbirth.ToShortDateString()); subject.Email = obj.Email; subject.EpidNo = obj.EpidNo; subject.LocalPhone = obj.LocalPhone; subject.HomePhone = obj.HomePhone; subject.ResidentialAddress = obj.ResidentialAddress; subject.UpdateBy = obj.UpdateBy; Save(subject); } }
public void Delete(int id, string username) { //throw new NotImplementedException(); TblBiodata s = GetById(id); if (s == null) { return; } var cmd = Context.Database.GetDbConnection().CreateCommand(); cmd.CommandText = "[dbo].[sp_delete_biodata] @biodata, @username"; var param1 = cmd.CreateParameter(); param1.ParameterName = "@biodata"; param1.Value = id; cmd.Parameters.Add(param1); var param2 = cmd.CreateParameter(); param2.ParameterName = "@username"; param2.Value = username; cmd.Parameters.Add(param2); try { Context.Database.GetDbConnection().Open(); // Run the sproc var reader = cmd.ExecuteReader(); } catch { } finally { Context.Database.GetDbConnection().Close(); } }
public async Task <IActionResult> Create([Bind("Id,Fullname,LegalGardianName,Dateofbirth,Gender,Email,EpidNo,LocalPhone,HomePhone,ResidentialAddress,InsertTime,InsertBy,UpdateTime,UpdateBy")] TblBiodata tblBiodata) { try { if (ModelState.IsValid) { tblBiodata.InsertBy = tblBiodata.UpdateBy = User.Identity.Name; biodata.Create(tblBiodata); /*_context.Add(tblBiodata); * await _context.SaveChangesAsync();*/ return(RedirectToAction(nameof(Index))); } } catch { ViewData["Error"] = "Duplicate EPID-NO"; ViewData["Random"] = tblBiodata.EpidNo; } ViewData["Gender"] = new SelectList(/*_context.TlkpGenders*/ genders.GetAll(), "Id", "Gender"); return(View(tblBiodata)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Fullname,LegalGardianName,Dateofbirth,Gender,Email,EpidNo,HomePhone,LocalPhone,ResidentialAddress,InsertTime,InsertBy,UpdateTime,UpdateBy")] TblBiodata tblBiodata) { if (id != tblBiodata.Id) { return(NotFound()); } if (ModelState.IsValid) { try { tblBiodata.UpdateBy = User.Identity.Name; biodata.Update(tblBiodata); /*_context.Update(tblBiodata); * await _context.SaveChangesAsync();*/ return(RedirectToAction(nameof(Index))); } catch (DbUpdateConcurrencyException) { if (!TblBiodataExists(tblBiodata.Id)) { return(NotFound()); } else { throw; } } catch { ViewData["Error"] = "Duplicate EPID-NO"; } //return RedirectToAction(nameof(Index)); } ViewData["Gender"] = new SelectList(/*_context.TlkpGenders*/ genders.GetAll(), "Id", "Gender"); return(View(tblBiodata)); }
public LabTestDetailsViewModel(TblBiodata _BioData, IMethodRepos _methods, ISpecimenRepos _specimen) //main to create { //perfect BioData = _BioData; //Method = _method; methods = _methods; //Indicators = new List<TblLabTestsIndicatorsValues>(); Specimen = new List <TblLabTestsSpecimen>(); LabTest = new TblLabTests(); LabTest.Approved = false; LabTest.Biodata = _BioData.Id; //LabTest.Method = _method.Id; /*foreach(var i in _method.TlkpTestIndicators) * { * TblLabTestsIndicatorsValues v = new TblLabTestsIndicatorsValues(); * v.Indicator = i.Id; * v.Method = _method.Id; * LabTest.TblLabTestsIndicatorsValues.Add(v); * * Indicators.Add(v); * * * }*/ foreach (var t in _specimen.GetAll()) { TblLabTestsSpecimen s = new TblLabTestsSpecimen(); s.Specimen = t.Id; s.SpecimenName = t.Type; LabTest.TblLabTestsSpecimen.Add(s); Specimen.Add(s); } }
public void Save(TblBiodata obj) { //throw new NotImplementedException(); Context.SaveChanges(); Context.Entry(obj).ReloadAsync(); }