public IHttpActionResult UpdateData([FromBody] Biodata req) { try { if (req != null) { using (var dc = new CRUDDataContext()) { var data = dc.Biodatas.FirstOrDefault(o => o.Username == req.Username); { data.Username = req.Username; data.Password = req.Password; data.Firstname = req.Firstname; data.Lastname = req.Lastname; dc.SubmitChanges(); return(Ok(data)); }; } } else { return(Unauthorized()); } } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public static Biodata GetByID(int ID) { Biodata biodata = new Biodata(); using (DataContext db = new DataContext()) { biodata = db.Biodata.Where(d => d.id == ID).First(); return(biodata); } }
public static Biodata GetByID(string ID) { Biodata pengguna = new Biodata(); using (DataContext db = new DataContext()) { pengguna = db.Biodata.Where(d => d.fullname == ID).First(); return(pengguna); } }
private void getBiodata_Click(object sender, EventArgs e) { List <Biodata> biodata = new List <Biodata>(); Biodata p = new Biodata() { Id = Convert.ToInt32(txtId.Text) }; Service1Client service = new Service1Client(); biodata.Add(service.GetBiodata(p)); dgvBiodata.DataSource = biodata; }
public ActionResult EditSimpan(Biodata biodata) { biodata.modified_by = Convert.ToInt64(Session["foo"]); if (BiodataRepo.Editbiodata(biodata)) { return(Json(new { EditSimpan = "Berhasil" }, JsonRequestBehavior.AllowGet)); //return json digunakan untuk memunculkan alert } else { return(Json(new { EditSimpan = "Gagal" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult EditSimpan(Biodata biodatamdl) { biodatamdl.modified_by = Convert.ToInt32(Session["foo"]); if (KirimTokenRepo.Editkirimtoken(biodatamdl)) { return(Json(new { EditToken = "Berhasil" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { EditToken = "Gagal" }, JsonRequestBehavior.AllowGet)); } }
private void btnHapus_Click(object sender, EventArgs e) { Biodata p = new Biodata() { Id = Convert.ToInt32(txtId.Text), }; Service1Client service = new Service1Client(); if (service.HapusBiodata(p) == 1) { MessageBox.Show("Biodata berhasil di hapus"); } }
public ActionResult SignUp(BiodataModel biodata, HttpPostedFileBase file) { if (ModelState.IsValid) { var SeachData = context.Biodatas.Where(x => x.Pass == biodata.Username).SingleOrDefault(); if (SeachData != null) { ModelState.AddModelError(string.Empty, "Student Name already exists."); return(View()); } } string imageUrl = ""; if (file != null) { string ImageName = System.IO.Path.GetFileName(file.FileName); string physicalPath = Server.MapPath("~/Profil/" + ImageName); file.SaveAs(physicalPath); imageUrl = ImageName; } try { Biodata Bio = new Biodata() { Username = biodata.Username, Alamat = biodata.Alamat, Email = biodata.Email, Pass = biodata.Pass, Makanan = biodata.Makanan, Film = biodata.Film, WDaftar = DateTime.Now, IdStat = 2, Foto = imageUrl, KTP = biodata.KTP }; context.Biodatas.InsertOnSubmit(Bio); context.SubmitChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
private void btnInsert_Click(object sender, EventArgs e) { Biodata p = new Biodata(); p.Id = Convert.ToInt32(txtId.Text); p.Nama = txtNama.Text; p.Umur = Convert.ToInt32(txtUmur.Text); Service1Client service = new Service1Client(); if (service.TambahBiodata(p) == 1) { MessageBox.Show("Biodata berhasil di simpan"); } }
public int Update(string id, RegisterViewModel userView) { User user = _context.Users.Single(u => u.UserName == id); Biodata biodata = _context.Biodatas.Find(user.Id); try { user.PasswordHash = BCrypt.Net.BCrypt.HashPassword(userView.Password); _context.SaveChanges(); return(1); } catch (Exception) { return(0); } }
public async Task <int> Create(RegisterViewModel userView) { User user = new User(); Biodata biodata = new Biodata(); try { user.UserName = userView.Id; user.Email = userView.Email; user.NormalizedUserName = user.UserName.ToUpper(); user.NormalizedEmail = user.Email.ToUpper(); user.PasswordHash = BCrypt.Net.BCrypt.HashPassword(userView.Password); user.PhoneNumber = userView.PhoneNumber; user.LockoutEnabled = true; user.EmailConfirmed = true; var create = await _context.Users.AddAsync(user); if (create.IsKeySet) { //var exist = await _roleManager.RoleExistsAsync("Employee"); UserRole userRole = new UserRole { UserId = user.Id, RoleId = _roleManager.FindByNameAsync("Sales").Result.Id }; _context.UserRoles.Add(userRole); biodata.FirstName = userView.FirstName; biodata.LastName = userView.Lastname; biodata.Address = userView.Address; biodata.CreatedAt = DateTimeOffset.Now; _context.Biodatas.Add(biodata); _context.SaveChanges(); return(1); } else { return(0); } } catch (Exception) { return(0); } }
private void btnEdit_Click(object sender, EventArgs e) { Biodata p = new Biodata() { Id = Convert.ToInt32(txtId.Text), Nama = txtNama.Text, Umur = Convert.ToInt32(txtUmur.Text) }; Service1Client service = new Service1Client(); if (service.EditBiodata(p) == 1) { MessageBox.Show("Biodata berhasil di edit"); } }
private void LoginSession() { //Login session Login login = new Login(); login.ShowDialog(); if (login.success) { //Get information about details account biodata = new Biodata(Properties.Settings.Default.Username); lblUsername.Text = biodata.firstname + " " + biodata.lastname; this.Show(); } else { this.Close(); } }
public static bool Editkirimtoken(Biodata biodatamdl) { var shortURL = RandomURL(); try { Biodata dep; using (DataContext db = new DataContext()) { dep = db.Biodata.Where(d => d.id == biodatamdl.id).First(); dep.modified_by = biodatamdl.modified_by; dep.modified_on = DateTime.Now; dep.token = shortURL; dep.expired_token = biodatamdl.expired_token; db.Entry(dep).State = EntityState.Modified;//dep diperlakukan sebagai Entry di dalam database kirim token (System.Data.Entity.EntityState.Modified) db.SaveChanges(); } MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); mail.From = new MailAddress("*****@*****.**"); mail.To.Add(biodatamdl.email); mail.Subject = "XSIS Token"; mail.IsBodyHtml = true; string htmlStr = "This is the new Token: " + shortURL + " valid until: " + biodatamdl.expired_token; mail.Body = htmlStr; SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Fastabiqul3khoirot"); SmtpServer.EnableSsl = true; //SmtpServer.Timeout = 12000; SmtpServer.Send(mail); //UpdateDB(email, shortURL); return(true); } catch (Exception) { return(false); } }
public IHttpActionResult Create([FromBody] Biodata req) { var result = new List <SelectResult>(); using (var dc = new CRUDDataContext()) { var data = new Biodata() { Username = req.Username, Password = req.Password, Firstname = req.Firstname, Lastname = req.Lastname }; dc.Biodatas.InsertOnSubmit(data); dc.SubmitChanges(); } return(Ok(result)); }
public static Boolean Editbiodata(Biodata biodata) { try { Biodata dep; using (DataContext db = new DataContext()) { dep = db.Biodata.Where(d => d.id == biodata.id).First(); dep.modified_by = biodata.modified_by; dep.modified_on = DateTime.Now; dep.fullname = biodata.fullname; dep.nick_name = biodata.nick_name; dep.pob = biodata.pob; dep.dob = biodata.dob; dep.gender = biodata.gender; dep.religion_id = biodata.religion_id; dep.high = biodata.high; dep.weight = biodata.weight; dep.nationality = biodata.nationality; dep.ethnic = biodata.ethnic; dep.hobby = biodata.hobby; dep.identity_type_id = biodata.identity_type_id; dep.identity_no = biodata.identity_no; dep.email = biodata.email; dep.phone_number1 = biodata.phone_number1; dep.phone_number2 = biodata.phone_number2; dep.parent_phone_number = biodata.parent_phone_number; dep.child_sequence = biodata.child_sequence; dep.how_many_brothers = biodata.how_many_brothers; dep.marital_status_id = biodata.marital_status_id; dep.mariage_year = biodata.mariage_year; db.Entry(dep).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } return(true); } catch (Exception) { return(false); } }
public static Boolean Deletebiodata(int ID, Biodata biodatamdl) { try { Biodata dep; using (DataContext db = new DataContext()) { dep = db.Biodata.Where(d => d.id == ID).First(); dep.is_delete = true; dep.deleted_by = biodatamdl.deleted_by; dep.deleted_on = DateTime.Now; db.Entry(dep).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } return(true); } catch (Exception) { return(false); } }
public async Task <ActionResult> Register([FromBody] ApplicantVM model) { Biodata biodata = new Biodata(); biodata.IdCard = model.IdCard; biodata.FirstName = model.FirstName; biodata.LastName = model.LastName; biodata.PlaceOfDate = model.PlaceOfDate; biodata.BirthDate = model.BirthDate; biodata.Religion = model.Religion; biodata.Gender = model.Gender; biodata.PhoneNumber = model.PhoneNumber; biodata.Address = model.Address; biodata.MaritalStatus = model.MaritalStatus; var result1 = await _biodataRepository.PostAsync(biodata); EducationalDetails education = new EducationalDetails(); education.Level = model.Level; education.Name = model.Name; education.Majors = model.Majors; education.YearOfEntry = model.YearOfEntry; education.GraduationYear = model.GraduationYear; education.Place = model.Place; education.FinalValue = model.FinalValue; var result2 = await _educationalDetailsRepository.PostAsync(education); WorkExperience workexp = new WorkExperience(); workexp.CompanyName = model.CompanyName; workexp.LastPosition = model.LastPosition; workexp.TypeOfBussiness = model.TypeOfBussiness; workexp.YearStartedWorking = model.YearStartedWorking; workexp.YearOfResign = model.YearOfResign; workexp.LastSalary = model.LastSalary; var result3 = await _workExperienceRepository.PostAsync(workexp); Document document = new Document(); document.fIdCard = model.fIdCard; document.fResume = model.fResume; document.fCV = model.fCV; document.fFamilyCard = model.fFamilyCard; document.fTranscripts = model.fTranscripts; document.fDiploma = model.fDiploma; document.fCertificate = model.fCertificate; var result4 = await _documentRepository.PostAsync(document); if (result1 != null && result2 != null && result3 != null && result4 != null) { Applicant applicant = new Applicant(); applicant.Biodata_Id = biodata.Id; applicant.EducationalDetails_Id = education.Id; applicant.Document_Id = document.Id; applicant.WorkExperience_Id = workexp.Id; applicant.User_Id = model.User_Id; await _applicantRepository.PostAsync(applicant); return(Ok("Registered Applicant Success!")); } else { return(BadRequest("Failed to register!")); } }