public async Task <Pasien> GetLoginByNoRmServices(string noRM) { Pasien pasien = new Pasien(); var uri = new Uri($"{urlWebServices}/Pasien/{noRM}"); try { var response = await client.GetAsync(uri); if (response.IsSuccessStatusCode) { var content = await response.Content.ReadAsStringAsync(); pasien = JsonConvert.DeserializeObject <Pasien>(content); } else { throw new Exception("Gagal Koneksi Server Login"); } } catch (Exception ex) { throw new Exception(ex.Message); } return(pasien); }
public async Task <IActionResult> Put(int id, [FromBody] Pasien pasien) { var result = await(from p in context.Pasien where p.PasienID == id select p).SingleOrDefaultAsync(); if (result != null) { try { result.Nama = pasien.Nama; result.Alamat = pasien.Alamat; result.Umur = pasien.Umur; result.Telpon = pasien.Telpon; context.Pasien.Update(result); await context.SaveChangesAsync(); return(Ok("Berhasil mengupdate data")); } catch (Exception ex) { return(BadRequest(ex.Message)); } } return(BadRequest("Data tidak ditemukan")); }
public IHttpActionResult PutPasien(string id, Pasien pasien) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != pasien.NIK) { return(BadRequest()); } db.Entry(pasien).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PasienExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PostPasien(Pasien pasien) { var pc = new PasiensController(); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Pasiens.Add(pasien); try { db.SaveChanges(); } catch (DbUpdateException) { if (pc.PasienExists(pasien.NIK)) { var responseMessage = "Pasien Sudah Terdaftar"; return(ResponseMessage(Request.CreateResponse(HttpStatusCode.BadRequest, new Exception(responseMessage)))); } else { throw; } } return(ResponseMessage(Request.CreateResponse(HttpStatusCode.Created, new Exception("Register Berhasil")))); }
public ActionResult DeleteConfirmed(string id) { Pasien pasien = db.Pasiens.Find(id); db.Pasiens.Remove(pasien); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult PostPasien([FromBody] Pasien pasien) { if (pasienContext.PostPasien(pasien)) { return(Ok(pasien)); } return(BadRequest()); }
public ActionResult Edit([Bind(Include = "id_Pasien,Nama_Pasien,Alamat_Pasien,Diagnosa_Penyakit")] Pasien pasien) { if (ModelState.IsValid) { db.Entry(pasien).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(pasien)); }
public ActionResult Edit([Bind(Include = "NIK,Nama,Alamat,TanggalLahir,KotaLahir,Email,JenisKelamin,Pekerjaan,StatusPernikahan,Agama,Password,ImageUrl")] Pasien pasien) { if (ModelState.IsValid) { db.Entry(pasien).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Agama = new SelectList(db.Agamas, "Id", "Nama", pasien.Agama); return(View(pasien)); }
public ActionResult Create([Bind(Include = "id_Pasien,Nama_Pasien,Alamat_Pasien,Diagnosa_Penyakit")] Pasien pasien) { if (ModelState.IsValid) { db.Pasiens.Add(pasien); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(pasien)); }
private async void BtnLogin_Clicked(object sender, EventArgs e) { if (String.IsNullOrEmpty(txtNoRM.Text)) { txtNoRM.HasError = true; return; } if (String.IsNullOrEmpty(txtPassword.Text)) { txtPassword.HasError = true; return; } loginServices = new LoginServices(); Pasien pasien = new Pasien(); pasien = await loginServices.GetLoginByNoRmServices(txtNoRM.Text); if (pasien.response == "ok") { string tglLahir = DateUtil.ConvertFormatDateTime(pasien.dtgllahir, "dd/MM/yyyy", "ddMMyyyy"); if ((tglLahir == txtPassword.Text) && (pasien.NoRM == txtNoRM.Text)) { App.IsUserLoggedIn = true; Preferences.Set("noRM", pasien.NoRM); Preferences.Set("namaPasien", pasien.NamaPasien); Preferences.Set("tglLahir", pasien.dtgllahir); Preferences.Set("alamat", pasien.alamat); if (_source == "Registration") { Navigation.InsertPageBefore(new RegistrationForm(), this); } else { Navigation.InsertPageBefore(new RegistrationHistoryForm(), this); } await Navigation.PopAsync(); } else { App.IsUserLoggedIn = false; await PopupNavigation.Instance.PushAsync(new DialogAlertCustom("Gagal Login", "Password Tidak Sesuai")); } } else { await PopupNavigation.Instance.PushAsync(new DialogAlertCustom("Gagal Login", pasien.deskripsiresponse)); } }
public static void Initialize(PasienDataContext context) { context.Database.EnsureCreated(); if (context.Pasien.Any()) { return; } var lstPasien = new Pasien[] { new Pasien { Nama = "Budi", Alamat = "Jl Mangga 12", Telpon = "667788", Umur = 45 }, new Pasien { Nama = "Amir", Alamat = "Jl Duren 12", Telpon = "889988", Umur = 48 }, new Pasien { Nama = "Bambang", Alamat = "Jl Sawo 12", Telpon = "445566", Umur = 24 }, new Pasien { Nama = "Joko", Alamat = "Jl Belimbing 99", Telpon = "115566", Umur = 28 }, new Pasien { Nama = "Ani", Alamat = "Jl Belimbing 23", Telpon = "455566", Umur = 22 } }; foreach (var pasien in lstPasien) { context.Pasien.Add(pasien); } context.SaveChanges(); var lstPengguna = new Pengguna[] { new Pengguna { Username = "******", Password = BCrypt.Net.BCrypt.HashPassword("erick") }, new Pengguna { Username = "******", Password = BCrypt.Net.BCrypt.HashPassword("budi") } }; foreach (var pengguna in lstPengguna) { context.Pengguna.Add(pengguna); } context.SaveChanges(); }
public async Task <IActionResult> Post([FromBody] Pasien pasien) { try { context.Pasien.Add(pasien); await context.SaveChangesAsync(); return(Ok("Data berhasil ditambah")); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
// GET: ListPasiens/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Pasien pasien = db.Pasiens.Find(id); if (pasien == null) { return(HttpNotFound()); } return(View(pasien)); }
public IHttpActionResult DeletePasien(string id) { Pasien pasien = db.Pasiens.Find(id); if (pasien == null) { return(NotFound()); } db.Pasiens.Remove(pasien); db.SaveChanges(); return(Ok(pasien)); }
// GET: ListPasiens/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Pasien pasien = db.Pasiens.Find(id); if (pasien == null) { return(HttpNotFound()); } ViewBag.Agama = new SelectList(db.Agamas, "Id", "Nama", pasien.Agama); return(View(pasien)); }