public HttpResponseMessage Put(int id, [FromBody] SignatureTable signature) { try { using (SignatureDBEntities entities = new SignatureDBEntities()) { var entity = entities.SignatureTables.FirstOrDefault(e => e.id == id); if (entity == null) { System.Diagnostics.Debug.WriteLine("Id tidak ditemukan di table"); } else { entity.status = signature.status; entity.approval = signature.approval; entities.SaveChanges(); System.Diagnostics.Debug.WriteLine("Sukses Sign File"); } var message = Request.CreateResponse(HttpStatusCode.Created, signature); message.Headers.Location = new Uri(Request.RequestUri + "/" + signature.id.ToString()); return(message); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public HttpResponseMessage Put(int id, [FromBody] m_signature signature) { string pathToFiles = HttpContext.Current.Server.MapPath("~/UploadFile/"); try { PictureSign picture = new PictureSign(); picture.Sign(pathToFiles + "input/" + signature.pdfName, pathToFiles + "input/sign_" + signature.pdfName, pathToFiles + "pic/" + signature.picName, signature.posX, signature.posY ); /*section save data to DB*/ using (SignatureDBEntities entities = new SignatureDBEntities()) { var entity = entities.SignatureTables .FirstOrDefault(e => e.id == id); if (entity == null) { System.Diagnostics.Debug.WriteLine("Id not found"); return(Request.CreateErrorResponse( HttpStatusCode.BadRequest, "Id not found")); } else { entity.author = signature.author; entity.title = signature.title; entity.subject = signature.subject; entity.keyword = signature.keyword; entity.reason = signature.reason; entity.email = signature.email; entity.issuerId = signature.issuerId; entity.requestorId = signature.requestorId; entity.status = "waiting"; entity.doubleSign = 1; entities.SaveChanges(); System.Diagnostics.Debug.WriteLine("Sukses Sign File"); } var message = Request.CreateResponse( HttpStatusCode.Created, signature); message.Headers.Location = new Uri( Request.RequestUri + "/" + signature.id.ToString() ); return(message); } } catch (Exception ex) { return(Request.CreateErrorResponse( HttpStatusCode.BadRequest, ex)); } }
public HttpResponseMessage Get() { using (SignatureDBEntities entities = new SignatureDBEntities()) { try { return(Request.CreateResponse(HttpStatusCode.OK, entities.Members.Where(e => e.memberRole.ToLower() == "Issuer").ToList())); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } } }
public HttpResponseMessage Post([FromBody] SignPic signPic) { string filePath = HttpContext.Current.Server.MapPath("~/UploadFile/pic/" + signPic.namePic); File.WriteAllBytes(filePath, Convert.FromBase64String(signPic.basePic)); using (SignatureDBEntities entities = new SignatureDBEntities()) { SignPic pic = new SignPic(); pic.memberId = signPic.memberId; pic.namePic = signPic.namePic; entities.SignPics.Add(pic); entities.SaveChanges(); } return(Request.CreateResponse(HttpStatusCode.OK, signPic)); }
public HttpResponseMessage Get(int id) { using (SignatureDBEntities entities = new SignatureDBEntities()) { try { return(Request.CreateResponse(HttpStatusCode.OK, entities.SignatureTables .FirstOrDefault(e => e.id == id))); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } } }
public HttpResponseMessage Get() { using (SignatureDBEntities entities = new SignatureDBEntities()) { try { return(Request.CreateResponse(HttpStatusCode.OK, entities.SignatureTables.OrderByDescending(e => e.id) .ToList())); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } } }
public HttpResponseMessage Get(string memberId) { using (SignatureDBEntities entities = new SignatureDBEntities()) { try { return(Request.CreateResponse(HttpStatusCode.OK, entities.Members .FirstOrDefault(e => e.memberId.ToLower() == memberId))); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } } }
public HttpResponseMessage Get(string memberId) { using (SignatureDBEntities entities = new SignatureDBEntities()) { try { return(Request.CreateResponse(HttpStatusCode.OK, entities.SignatureTables .Where(e => e.requestorId.ToLower() == memberId) .OrderByDescending(f => f.id) .ToList())); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } } }
public async Task <FileUploadDetails> Post() { // file path var fileuploadPath = HttpContext.Current.Server.MapPath("~/UploadFile/input"); // var multiFormDataStreamProvider = new MultiFileUploadProvider(fileuploadPath); // Read the MIME multipart asynchronously await Request.Content.ReadAsMultipartAsync(multiFormDataStreamProvider); string uploadingFileName = multiFormDataStreamProvider .FileData.Select(x => x.LocalFileName).FirstOrDefault(); var nameFile = Path.GetFileName(uploadingFileName); // var random = RandomString(10); // System.Diagnostics.Debug.WriteLine(nameFile); using (SignatureDBEntities entities = new SignatureDBEntities()) { SignatureTable signa = new SignatureTable(); signa.pdfName = nameFile; entities.SignatureTables.Add(signa); entities.SaveChanges(); int idSign = signa.id; return(new FileUploadDetails { FilePath = uploadingFileName, FileName = Path.GetFileName(uploadingFileName), FileLength = new FileInfo(uploadingFileName).Length, FileCreatedTime = DateTime.Now.ToLongDateString(), IdSign = idSign }); } }
public HttpResponseMessage Post([FromBody] SignatureTable signature) { try { Cert myCert = null; try { myCert = new Cert(pathToFiles + "sertifikat/" + signature.certName, signature.password); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } //Adding Meta Datas MetaData MyMD = new MetaData(); MyMD.Author = signature.author; MyMD.Title = signature.title; MyMD.Subject = signature.subject; MyMD.Keywords = signature.keyword; PDFSigner pdfs = new PDFSigner(pathToFiles + "input/" + signature.pdfName, pathToFiles + "output/sign_" + signature.pdfName, myCert, MyMD); pdfs.Sign(signature.reason, signature.email, signature.location, true); using (SignatureDBEntities entities = new SignatureDBEntities()) { entities.SignatureTables.Add(signature); entities.SaveChanges(); var message = Request.CreateResponse(HttpStatusCode.Created, signature); message.Headers.Location = new Uri(Request.RequestUri + "/" + signature.id.ToString()); return(message); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public IdentityResult Register(AccountModel model) { var userStore = new UserStore <ApplicationUser>(new ApplicationDbContext()); var manager = new UserManager <ApplicationUser>(userStore); var user = new ApplicationUser() { UserName = model.UserName, Email = model.Email }; user.FirstName = model.FirstName; user.LastName = model.LastName; manager.PasswordValidator = new PasswordValidator { RequiredLength = 3 }; IdentityResult result = manager.Create(user, model.Password); manager.AddToRoles(user.Id, model.Roles); using (SignatureDBEntities entities = new SignatureDBEntities()) { try { Member member = new Member(); member.memberId = user.Id; member.firstName = model.FirstName; member.lastName = model.LastName; member.memberRole = model.Roles[0]; entities.Members.Add(member); entities.SaveChanges(); } catch (Exception ex) { throw ex; } } return(result); }
public HttpResponseMessage Put(int id, [FromBody] SignatureTable signature) { try { using (SignatureDBEntities entities = new SignatureDBEntities()) { var entity = entities.SignatureTables.FirstOrDefault(e => e.id == id); if (entity == null) { System.Diagnostics.Debug.WriteLine("Id tidak ditemukan di table"); } else { entity.author = signature.author; entity.title = signature.title; entity.subject = signature.subject; entity.keyword = signature.keyword; entity.reason = signature.reason; entity.email = signature.email; entity.requestorId = signature.requestorId; entity.issuerId = signature.issuerId; entity.status = "waiting"; entities.SaveChanges(); System.Diagnostics.Debug.WriteLine("Success request signature"); } var message = Request.CreateResponse(HttpStatusCode.Created, signature); message.Headers.Location = new Uri(Request.RequestUri + "/" + signature.id.ToString()); return(message); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public HttpResponseMessage Put(int id, [FromBody] m_signature signature) { try { /*section processing certificate*/ Cert myCert = null; try { myCert = new Cert( pathToFiles + "sertifikat/" + signature.certName, signature.password ); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } /*section processing Signature*/ MetaData MyMD = new MetaData(); MyMD.Author = signature.author; MyMD.Title = signature.title; MyMD.Subject = signature.subject; MyMD.Keywords = signature.keyword; PDFSigner pdfs = new PDFSigner( pathToFiles + "input/" + signature.pdfName, pathToFiles + "output/sign_" + signature.pdfName, myCert, MyMD ); pdfs.Sign(signature.reason, signature.email, signature.location, pathToFiles + "pic/" + signature.picName, signature.visible, signature.posX, signature.posY ); /*section save data to DB*/ using (SignatureDBEntities entities = new SignatureDBEntities()) { var entity = entities.SignatureTables .FirstOrDefault(e => e.id == id); if (entity == null) { System.Diagnostics.Debug.WriteLine("Id not found"); return(Request.CreateErrorResponse( HttpStatusCode.BadRequest, "Id not found")); } else { entity.author = signature.author; entity.title = signature.title; entity.subject = signature.subject; entity.keyword = signature.keyword; entity.reason = signature.reason; entity.email = signature.email; entity.location = signature.location; entity.certName = signature.certName; entity.issuerId = signature.issuerId; entity.requestorId = signature.requestorId; entity.status = "sign"; entity.approval = 1; entities.SaveChanges(); System.Diagnostics.Debug.WriteLine("Sukses Sign File"); } var message = Request.CreateResponse( HttpStatusCode.Created, signature); message.Headers.Location = new Uri( Request.RequestUri + "/" + signature.id.ToString() ); return(message); } } catch (Exception ex) { return(Request.CreateErrorResponse( HttpStatusCode.BadRequest, ex)); } }