public IHttpActionResult Postcertificate(certificate certificate) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var file = HttpContext.Current.Request.Files.Count > 0 ? HttpContext.Current.Request.Files[0] : null; if (file != null && file.ContentLength > 0) { //var fileName = Path.GetFileName(file.FileName); string filename = Path.GetFileNameWithoutExtension(file.FileName); string extention = Path.GetExtension(file.FileName); filename = filename + DateTime.Now.ToString("yymmddssfff") + extention; var path = Path.Combine( HttpContext.Current.Server.MapPath("~/Content/uploads/images/"), filename ); certificate.image = "~/Content/uploads/images/" + filename; file.SaveAs(path); } db.certificates.Add(certificate); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = certificate.id }, certificate)); }
public IHttpActionResult Putcertificate(int id, certificate certificate) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != certificate.id) { return(BadRequest()); } db.Entry(certificate).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!certificateExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult edit_cert(certificate certp, IEnumerable <HttpPostedFileBase> file) { string[] file_names = new string[4]; foreach (var a in file) { int i = 0; if (a != null) { string guid_file = Guid.NewGuid().ToString(); file_names[i] = guid_file + Path.GetExtension(a.FileName); a.SaveAs(Server.MapPath("~/Files/" + guid_file + Path.GetExtension(a.FileName))); } } var cert = db_certs.certificates.First(d => d.id == certp.id); cert.category = certp.category; cert.name = certp.name; cert.startDate = certp.startDate; cert.endDate = certp.endDate; cert.getDate = certp.getDate; cert.vendorID = certp.vendorID; cert.file1_name = file_names[0]; cert.file2_name = file_names[1]; cert.file3_name = file_names[2]; cert.file4_name = file_names[3]; db_certs.SaveChanges(); return(RedirectToAction(@"view_certs/" + cert.ownerID, "Home")); }
protected void btnSubmit_Click(object sender, EventArgs e) { var CertificateSession = NhibernateDataProvider.OpenSession(); { using (var SaveCertificate = CertificateSession.BeginTransaction()) { certificate NewCertificate = new certificate(); NewCertificate.AdmNo = TextBox2.Text; NewCertificate.course = DropDownList1.SelectedIndex.ToString(); NewCertificate.DateJoined = Convert.ToDateTime(TextBox3.Text); NewCertificate.dob = Convert.ToDateTime(TextBox7.Text); NewCertificate.guardianEmail = TextBox10.Text; NewCertificate.guardiansContact = TextBox11.Text; NewCertificate.guardiansName = TextBox12.Text; NewCertificate.StudentsFullNames = TextBox6.Text + " " + TextBox5.Text + " " + TextBox4.Text; NewCertificate.StudentsID = TextBox1.Text; NewCertificate.year = DropDownList1.SelectedIndex; CertificateSession.Save(NewCertificate); SaveCertificate.Commit(); loadStudents(); } } }
private CertificateInfo toCertificateInfo(certificate actalisCert) { // Costruzione delle informazioni sul certificato. CertificateInfo ci = new CertificateInfo(); try { //controllare sta cosa qui sotto ci.X509Certificate = Convert.FromBase64String(actalisCert.certCert); ci.ThumbPrint = actalisCert.certFinger256; ci.IssuerName = actalisCert.certIssuer.issuerName; ci.SubjectName = actalisCert.certName; ci.RevocationStatus = (actalisCert.certRevocation.certRevoked == false) ? 0 : 1; ci.SerialNumber = actalisCert.certSerialNo; ci.ValidFromDate = actalisCert.certValFrom; ci.ValidToDate = actalisCert.certValUntil; ci.SignatureAlgorithm = "N.A."; if (actalisCert.certRevocation.certRevoked) { ci.RevocationStatusDescription = actalisCert.certRevocation.revocationReason; ci.RevocationDate = actalisCert.certRevocation.revocationDate; revoked = true; } if (!actalisCert.certTimeValid) { certExpired = true; } } catch (Exception ex) { logger.ErrorFormat("Errore in toCertificateInfo {0} stk {1}", ex.Message, ex.StackTrace); } return(ci); }
private void btn_Certificate_Click(object sender, EventArgs e) { //Show certificate if all 20 level completed this.Hide(); certificate certi_page = new certificate(); certi_page.Show(); }
public IHttpActionResult Getcertificate(int id) { certificate certificate = db.certificates.Find(id); if (certificate == null) { return(NotFound()); } return(Ok(certificate)); }
public IHttpActionResult Postcertificate(certificate certificate) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.certificates.Add(certificate); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = certificate.id }, certificate)); }
public IHttpActionResult Deletecertificate(int id) { certificate certificate = db.certificates.Find(id); if (certificate == null) { return(NotFound()); } db.certificates.Remove(certificate); db.SaveChanges(); return(Ok(certificate)); }
public ActionResult edit_cert(int id) { certificate cert = db_certs.certificates.First(d => d.id == id); ViewBag.cert = cert; ViewBag.vendors = db_certs.vendors; ViewBag.current_ven = db_certs.vendors.First(v => v.id == cert.vendorID); ViewBag.categories = db_certs.categories; ViewBag.current_cat = db_certs.categories.First(c => c.id == cert.category); ViewBag.img1 = @"~/Files/" + cert.file1_name; ViewBag.img2 = @"~/Files/" + cert.file2_name; ViewBag.img3 = @"`/Files/" + cert.file3_name; ViewBag.img4 = @"~/Files/" + cert.file4_name; return(View()); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ReportViewer1.ProcessingMode = ProcessingMode.Local; ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report.rdlc"); // dsEmployees = GetData("SELECT * FROM Employees"); certificate dscertificate = GetData("select * from certificate"); ReportDataSource datasource = new ReportDataSource("certificate", dscertificate.Tables[0]); ReportViewer1.LocalReport.DataSources.Clear(); ReportViewer1.LocalReport.DataSources.Add(datasource); } }
public ActionResult Edit(Guid?id) { certificate certificateModel = null; ViewBag.cctypes = new List <SelectListItem> { new SelectListItem { Selected = true, Value = "CPCertificateStudent2016", Text = "CP Certificate Student 2016" }, new SelectListItem { Selected = false, Value = "CPCertificateVolunteer2016", Text = "CP Certificate Volunteer 2016" }, new SelectListItem { Selected = false, Value = "MrshidyCertificateStudent", Text = "Mrshidy Certificate Student" }, new SelectListItem { Selected = false, Value = "MrshidyCertificateVolunteer", Text = "Mrshidy Certificate Volunteer" }, new SelectListItem { Selected = false, Value = "PFCertificate_Student", Text = "PF Certificate Student" }, new SelectListItem { Selected = false, Value = "PFCertificate_Volunteer", Text = "PF Certificate Volunteer" }, new SelectListItem { Selected = false, Value = "SafeerCertificate_Student", Text = "Safeer Certificate Student" }, new SelectListItem { Selected = false, Value = "SafeerCertificate_Volunteer", Text = "Safeer Certificate Volunteer" }, new SelectListItem { Selected = false, Value = "SYCCertificates-Student", Text = "SYC Certificate Student" }, new SelectListItem { Selected = false, Value = "SYCCertificates-Volunteer", Text = "SYC Certificate Volunteer" } }; if (id == null) { certificateModel = new certificate(); } else { var certificateRepo = new CertificateRepository(); certificateModel = certificateRepo.GetByRowId(id.Value); } return(View(certificateModel)); }
public ActionResult CertViewFull(int id) { certificate certificate = db_certs.certificates.First(c => c.id == id); owner owner = db_certs.owners.First(o => o.id == certificate.ownerID); vendor vendor = db_certs.vendors.First(v => v.id == certificate.vendorID); ViewBag.certificate = certificate; ViewBag.owner = owner; ViewBag.vendor = vendor; ViewBag.img1 = @"~/Files/" + certificate.file1_name; ViewBag.img2 = @"~/Files/" + certificate.file2_name; ViewBag.img3 = @"~/Files/" + certificate.file3_name; ViewBag.img4 = @"~/Files/" + certificate.file4_name; return(View()); }
public IHttpActionResult Editcertificate(certificate certificate) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var file = HttpContext.Current.Request.Files.Count > 0 ? HttpContext.Current.Request.Files[0] : null; if (file != null && file.ContentLength > 0) { //var fileName = Path.GetFileName(file.FileName); string filename = Path.GetFileNameWithoutExtension(file.FileName); string extention = Path.GetExtension(file.FileName); filename = filename + DateTime.Now.ToString("yymmddssfff") + extention; var path = Path.Combine( HttpContext.Current.Server.MapPath("~/Content/uploads/images/"), filename ); certificate.image = "~/Content/uploads/images/" + filename; file.SaveAs(path); } db.Entry(certificate).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!certificateExists(certificate.id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
protected void tgenerate_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=Dell\\sqlexpress;Initial Catalog=learning;Integrated Security=True;Pooling=False"); certificate dscertificate = GetData("select * from certificate where studentid=@studentid"); // con.Parameters.AddWithValue("studentid", tresult.Text); ReportDataSource datasource = new ReportDataSource("certificate", dscertificate.Tables[0]); ReportViewer1.LocalReport.DataSources.Clear(); ReportViewer1.LocalReport.DataSources.Add(datasource); //SqlCommand cmd = new SqlCommand("select * from certificate where studentid=studentid", con); //cmd.Parameters.AddWithValue("studentid", tresult.Text); //SqlDataAdapter sda = new SqlDataAdapter(cmd); //using (certificate dscertificate = new certi ficate()) //{ // sda.Fill(dscertificate, "DataTable1"); // //return dscertificate; //} //DataTable dt = new DataTable(); //sda.Fill(dt); //con.Open(); //cmd.ExecuteNonQuery(); //con.Close(); //if (dt.Rows.Count > 0) //{ // Response.Redirect("result.aspx"); //} //else //{ // Label1.Text = "jhhxfj"; // //Label1.ForeColor = System.Drawing.Color.Red; //} }
private certificate GetData(string query) { SqlCommand cmd = new SqlCommand(query); SqlConnection con = new SqlConnection("Data Source=Dell\\sqlexpress;Initial Catalog=learning;Integrated Security=True;Pooling=False"); { using (SqlDataAdapter sda = new SqlDataAdapter()) { SqlCommand cmd1 = new SqlCommand("select * from certificate where studentid=@studentid", con); cmd.Parameters.AddWithValue("studentid", tresult.Text); cmd.Connection = con; sda.SelectCommand = cmd; using (certificate dscertificate = new certificate()) { sda.Fill(dscertificate, "DataTable1"); return(dscertificate); } } } }
public ActionResult delete_image(string @name, int por, int id) { certificate cer = db_certs.certificates.FirstOrDefault(c => c.id == id); string fn = Path.GetFileName(name); if (fn != null) { System.IO.File.Delete(Server.MapPath("~/Files/" + fn)); switch (por) { case 1: cer.file1_name = null; break; case 2: cer.file2_name = null; break; case 3: cer.file3_name = null; break; case 4: cer.file4_name = null; break; } db_certs.SaveChanges(); } return(RedirectToAction(@"CertViewFull/" + id, "Home")); }
public ActionResult add_certs(certificate cert, IEnumerable <HttpPostedFileBase> file) { string[] file_names = new string[4]; foreach (var a in file) { int i = 0; if (a != null) { string guid_file = Guid.NewGuid().ToString(); file_names[i] = guid_file + Path.GetExtension(a.FileName); a.SaveAs(Server.MapPath("~/Files/" + guid_file + Path.GetExtension(a.FileName))); } } cert.file1_name = file_names[0]; cert.file2_name = file_names[1]; cert.file3_name = file_names[2]; cert.file4_name = file_names[3]; db_certs.certificates.Add(cert); db_certs.SaveChanges(); return(RedirectToAction(@"view_certs/" + cert.ownerID, "Home")); }
DisplayX509Certificate(certificate, IntPtr.Zero);
public void SaveData(AdminCertificateIdViewModel model, List <CertificateDocumentViewModel> documentList, int userId) { if (model.Id > 0) { certificate certificate = _db.certificates.Where(x => x.Id == model.Id).FirstOrDefault(); certificate.Name = model.Name; certificate.Type = (int)model.TypeId; certificate.Body = model.Body; certificate.Number = model.Number; certificate.AssignTo = model.AssignToId; certificate.InRelationTo = model.InRelationToId; var validFromToString = DateTime.ParseExact(model.ValidFrom, inputFormat, CultureInfo.InvariantCulture); certificate.ValidFrom = Convert.ToDateTime(validFromToString.ToString(outputFormat)); var ExpiryDateToString = DateTime.ParseExact(model.ExpiryDate, inputFormat, CultureInfo.InvariantCulture); certificate.ExpiringDate = Convert.ToDateTime(ExpiryDateToString.ToString(outputFormat));; certificate.Status = (int)model.StatusId; certificate.AlertBeforeDays = model.AlertBeforeDays; certificate.Description = model.Description; certificate.Mandatory = model.Mandatory; certificate.Validate = model.Validate; certificate.LastModifiedBy = userId; certificate.LastModified = DateTime.Now; _db.SaveChanges(); foreach (var item in _db.certificate_document.Where(x => x.CertificateId == certificate.Id).ToList()) { _db.certificate_document.Remove(item); _db.SaveChanges(); } foreach (var item in documentList) { certificate_document certificateDocument = new certificate_document(); certificateDocument.CertificateId = certificate.Id; certificateDocument.NewName = item.newName; certificateDocument.OriginalName = item.originalName; certificateDocument.Description = item.description; certificateDocument.Archived = false; certificateDocument.UserIDCreatedBy = userId; certificateDocument.CreatedDate = DateTime.Now; certificateDocument.UserIDLastModifiedBy = userId; certificateDocument.LastModified = DateTime.Now; _db.certificate_document.Add(certificateDocument); _db.SaveChanges(); } } else { certificate certificate = new certificate(); certificate.Name = model.Name; certificate.Type = (int)model.TypeId; certificate.Body = model.Body; certificate.Number = model.Number; certificate.AssignTo = model.AssignToId; certificate.InRelationTo = model.InRelationToId; var validFromToString = DateTime.ParseExact(model.ValidFrom, inputFormat, CultureInfo.InvariantCulture); certificate.ValidFrom = Convert.ToDateTime(validFromToString.ToString(outputFormat)); var ExpiryDateToString = DateTime.ParseExact(model.ExpiryDate, inputFormat, CultureInfo.InvariantCulture); certificate.ExpiringDate = Convert.ToDateTime(ExpiryDateToString.ToString(outputFormat));; certificate.Status = (int)model.StatusId; certificate.AlertBeforeDays = model.AlertBeforeDays; certificate.Description = model.Description; certificate.Mandatory = model.Mandatory; certificate.Validate = model.Validate; certificate.Archived = false; certificate.CreateBy = userId; certificate.CreatedDate = DateTime.Now; certificate.LastModifiedBy = userId; certificate.LastModified = DateTime.Now; _db.certificates.Add(certificate); _db.SaveChanges(); foreach (var item in documentList) { certificate_document certificateDocument = new certificate_document(); certificateDocument.CertificateId = certificate.Id; certificateDocument.NewName = item.newName; certificateDocument.OriginalName = item.originalName; certificateDocument.Description = item.description; certificateDocument.Archived = false; certificateDocument.UserIDCreatedBy = userId; certificateDocument.CreatedDate = DateTime.Now; certificateDocument.UserIDLastModifiedBy = userId; certificateDocument.LastModified = DateTime.Now; _db.certificate_document.Add(certificateDocument); _db.SaveChanges(); } } }
public ActionResult Edit(certificate cer, HttpPostedFileBase file) { var certificateRepo = new CertificateRepository(); certificate cerModel = null; if (cer.Id == 0) { cerModel = new certificate(); cerModel.RowGUID = Guid.NewGuid(); if (file == null) { ViewBag.cctypes = new List <SelectListItem> { new SelectListItem { Selected = true, Value = "CPCertificateStudent2016", Text = "CP Certificate Student 2016" }, new SelectListItem { Selected = false, Value = "CPCertificateVolunteer2016", Text = "CP Certificate Volunteer 2016" }, new SelectListItem { Selected = false, Value = "MrshidyCertificateStudent", Text = "Mrshidy Certificate Student" }, new SelectListItem { Selected = false, Value = "MrshidyCertificateVolunteer", Text = "Mrshidy Certificate Volunteer" }, new SelectListItem { Selected = false, Value = "PFCertificate_Student", Text = "PF Certificate Student" }, new SelectListItem { Selected = false, Value = "PFCertificate_Volunteer", Text = "PF Certificate Volunteer" }, new SelectListItem { Selected = false, Value = "SafeerCertificate_Student", Text = "Safeer Certificate Student" }, new SelectListItem { Selected = false, Value = "SafeerCertificate_Volunteer", Text = "Safeer Certificate Volunteer" }, new SelectListItem { Selected = false, Value = "SYCCertificates-Student", Text = "SYC Certificate Student" }, new SelectListItem { Selected = false, Value = "SYCCertificates-Volunteer", Text = "SYC Certificate Volunteer" } }; ViewBag.NeedFile = true; return(View(cer)); } } else { cerModel = certificateRepo.Get(cer.Id); } cerModel.Name = cer.Name; cerModel.Type = cer.Type; cerModel.TypeCertificate = cer.TypeCertificate; if (file != null) { string fileName = "~/Uploads/CertificateLibrary/" + System.IO.Path.GetFileName(file.FileName); string filePath = Server.MapPath(fileName); file.SaveAs(filePath); cerModel.UploadFilePath = fileName; } if (cer.Id == 0) { certificateRepo.Post(cerModel); } else { certificateRepo.Put(cer.Id, cerModel); } return(RedirectToAction("Index")); }