public ActionResult GetNotebyId(string id) { string username = getUsername(); NOTES notes = _context.notes.Find(id); if (notes != null) { IEnumerable <Attachments> at = _context.attachments.AsEnumerable(); List <mAttachments> newat = new List <mAttachments>(); foreach (Attachments attachments in at) { if (attachments.noteID == notes.noteID) { mAttachments m = new mAttachments(); m.AID = attachments.AID; m.url = attachments.url; newat.Add(m); } } if (notes.EMAIL == username) { return(StatusCode(200, new{ ID = notes.noteID, Content = notes.content, Title = notes.title, Created_On = notes.created_on, last_updated_on = notes.last_updated_on, attachments = newat })); } else { return(StatusCode(401, new{ result = "Not Authorized" })); } } else { return(StatusCode(401, new{ result = "Note Absent" })); } }
public void Remove(int ida, int idb) { NOTES note = context.NOTES.Find(ida, idb); context.NOTES.Remove(note); context.SaveChanges(); }
public ActionResult putnote(string id, [FromBody] NOTES n) { string username = getUsername(); NOTES note = _context.notes.Find(id); if (note.EMAIL == username) { var ID = note.noteID; //IEnumerable<Attachments> a = _context.attachments.AsEnumerable(); var created = note.created_on; _context.notes.Remove(note); _context.SaveChanges(); var notes = new NOTES { noteID = ID, created_on = created, content = n.content, title = n.title, last_updated_on = DateTime.Now, EMAIL = username }; _context.Add(notes); _context.SaveChanges(); return(StatusCode(204, new{ Result = "Note Updated Successfully" })); } else { return(StatusCode(401, new{ result = "Not Authorized" })); } }
public ActionResult GetNotebyId(string id) { _log.LogInformation("NOTE is inserted"); statsDPublisher.Increment("_NOTE_GETBYID_API"); string username = getUsername(); NOTES notes = _context.notes.Find(id); IEnumerable <Attachments> at = _context.attachments.AsEnumerable(); List <mAttachments> newat = new List <mAttachments>(); foreach (Attachments attachments in at) { if (attachments.noteID == notes.noteID) { mAttachments m = new mAttachments(); m.AID = attachments.AID; m.url = attachments.url; newat.Add(m); } } if (notes.EMAIL == username) { return(StatusCode(200, new{ ID = notes.noteID, Content = notes.content, Title = notes.title, Created_On = notes.created_on, last_updated_on = notes.last_updated_on, attachments = newat })); } else { return(StatusCode(401, new{ result = "Not Authorized" })); } }
public ActionResult GetNoteAttachmentbyId(string id) { string username = getUsername(); NOTES notes = _context.notes.Find(id); IEnumerable <Attachments> at = _context.attachments.AsEnumerable(); List <mAttachments> newat = new List <mAttachments>(); foreach (Attachments attachments in at) { if (attachments.noteID == notes.noteID) { mAttachments m = new mAttachments(); m.AID = attachments.AID; m.url = attachments.url; newat.Add(m); } } if (notes.EMAIL == username) { return(StatusCode(200, new{ attachments = newat })); } else { return(StatusCode(401, new{ result = "Not Authorized" })); } }
void Start() { Instance = this; // Initiate the singleton PlayerPrefs.SetInt("PlayerCurrentLives", playerLives); // Save between scenes playerLives = PlayerPrefs.GetInt("PlayerCurrentLives"); // Get saved value myRigidBody2D = GetComponent<Rigidbody2D>(); // Set the shorthand version StartCoroutine(SeparateThreadWithTime()); GameObject.Find("ObjectName"); // Effective way to find objects fast }
[HttpPost]//Method to take in the new note for the donor public ActionResult AddNote(int id, string note) { NOTES notes = new NOTES(); notes.DonorId = id; notes.Note = note; notes.DateMade = DateTime.Now; ntRepo.Add(notes); return(RedirectToAction("Details", new { id })); }
public ActionResult putnoteAttachent(string id, IFormFile file, string aid) { NOTES note = _context.notes.Find(id); Attachments a = _context.attachments.Find(aid); if (note != null && a != null) { string fileName = (file.FileName + rand.ToString()); rand++; // var uniqueFileName = GetUniqueFileName(file.FileName); var uploads = Path.Combine(Directory.GetCurrentDirectory(), fileName); var filePath = Path.Combine(uploads); if (file.Length > 0) { using (var stream = new FileStream(filePath, FileMode.Create)) file.CopyToAsync(stream); } string username = getUsername(); if (note.EMAIL == username) { var newaid = a.AID; var noteid = a.noteID; _context.attachments.Remove(a); _context.SaveChanges(); var newa = new Attachments { AID = newaid, noteID = noteid, url = filePath, FileName = file.FileName, length = file.Length }; _context.Add(newa); _context.SaveChanges(); return(StatusCode(204, new{ Result = "Note Updated Successfully" })); } else { return(StatusCode(401, new{ result = "Not Authorized" })); } } else { return(StatusCode(401, new{ result = "Note Absent" })); } }
public ActionResult Deletenote(string id) { string username = getUsername(); NOTES note = _context.notes.Find(id); if (note != null) { IEnumerable <Attachments> at = _context.attachments.AsEnumerable(); if (note.EMAIL == username) { var path = ""; foreach (Attachments atchm in at) { if (atchm.noteID == id) { path = Path.Combine(Directory.GetCurrentDirectory(), atchm.FileName); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } _context.attachments.Remove(atchm); } } _context.notes.Remove(note); _context.SaveChanges(); return(StatusCode(204, new{ Result = "Note Deleted Successfully" })); } else { return(StatusCode(401, new{ result = "Not Authorized" })); } } else { return(StatusCode(401, new{ result = "note Absent" })); } }
public NOTES AddNote(string QRID, string UID, string TXTNOTE, string TYPEN, string LOC) { NOTES n = new NOTES(); //////////////////////////////////////// try { string connectionString = ConfigurationManager.ConnectionStrings["ConnDB"].ConnectionString; MySqlConnection conn = new MySqlConnection(connectionString); string query = @"INSERT INTO notes (NID, QRID, UID, UPDATEDATE, TYPEN, TXTNOTE, LOC) VALUES (NULL, @QRID, @UID, CURRENT_TIMESTAMP,@TYPEN,@TXTNOTE ,@LOC);"; MySqlCommand cmd = new MySqlCommand(query, conn); cmd.Parameters.AddWithValue("@QRID", QRID); cmd.Parameters.AddWithValue("@UID", UID); cmd.Parameters.AddWithValue("@TYPEN", TYPEN); cmd.Parameters.AddWithValue("@TXTNOTE", TXTNOTE); cmd.Parameters.AddWithValue("@LOC", LOC); conn.Open(); int res = cmd.ExecuteNonQuery(); if (res == 1) { n.MSG = "TRUE"; n.CODE = "100"; } else { n.MSG = "FALSE"; n.CODE = "200"; } conn.Close(); return(n); ///////////////////////////////////////////////////////////////////////////////////////////// } catch (Exception ex) { n.MSG = ex.Message; n.CODE = "500"; return(n); } //////////////////////////////////////// }
public static NoteName ParseNoteName(string value) { // A regex to validate the input: ^([ABDEG]b?|[ACDFG]#?)$ value = (value ?? string.Empty).Trim(); if (string.IsNullOrEmpty(value)) { throw new ArgumentNullException(nameof(value)); } value = value.Replace("♯", "#"); value = value.Replace("♭", "b"); if (Enum.TryParse(value, true, out NoteName note)) { return(note); } const string NOTES = "ABCDEFG"; if (value.Length == 2 && NOTES.Contains(char.ToUpper(value[0]))) { if (value.Contains("#")) { int noteIdx = NOTES.IndexOf(char.ToUpper(value[0])); string flatNoteName = NOTES[(noteIdx + 1) % NOTES.Length] + "b"; if (Enum.TryParse(flatNoteName, true, out note)) { return(note); } } } ////should have the same result as directly parsing the value //else if (value.Length == 1 && NOTES.Contains(value.ToUpper())) // return (NoteName)Enum.Parse(typeof(NoteName), value.ToUpper()); throw new InvalidCastException("Invalid note name"); }
public ActionResult Deletenoteattchment(string id, string atid) { string username = getUsername(); NOTES note = _context.notes.Find(id); if (note != null) { Attachments a = _context.attachments.Find(atid); var path = Path.Combine(Directory.GetCurrentDirectory(), a.FileName); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } if (note.EMAIL == username) { if (a.noteID == note.noteID && a.AID == atid) { _context.attachments.Remove(a); } _context.SaveChanges(); return(StatusCode(204, new{ Result = "Note Deleted Successfully" })); } else { return(StatusCode(401, new{ result = "Not Authorized" })); } } else { return(StatusCode(401, new{ result = "note Absent" })); } }
public ActionResult createNotes(NOTES n, IFormFile file) { if (ModelState.IsValid) { _log.LogInformation("NOTE is inserted"); statsDPublisher.Increment("_NOTE_API"); var authHeader = AuthenticationHeaderValue.Parse(Request.Headers["Authorization"]); var credentialBytes = Convert.FromBase64String(authHeader.Parameter); var credentials = Encoding.UTF8.GetString(credentialBytes).Split(':'); var username = credentials[0]; var fileTransferUtility = new TransferUtility(s3Client); string fileName = (rand.ToString() + file.FileName); rand++; var uploads = Path.Combine(Directory.GetCurrentDirectory(), file.FileName); var filePath = Path.Combine(uploads); if (file.Length > 0) { using (var stream = new FileStream(filePath, FileMode.Create)) file.CopyToAsync(stream); } fileTransferUtility.UploadAsync(filePath, bucketName, fileName); GetPreSignedUrlRequest request = new GetPreSignedUrlRequest(); request.BucketName = bucketName; request.Key = fileName; request.Expires = DateTime.Now.AddYears(2); request.Protocol = Protocol.HTTP; string url = fileTransferUtility.S3Client.GetPreSignedURL(request); var Attachment = new Attachments { url = url, FileName = fileName, length = file.Length, noteID = n.noteID }; _context.Add(Attachment); mAttachments att = new mAttachments(); att.AID = Attachment.AID; att.url = Attachment.url; _context.SaveChanges(); var notes = new NOTES { EMAIL = username, attachments = Attachment, content = n.content, created_on = DateTime.Now, title = n.title, last_updated_on = DateTime.Now }; _context.Add(notes); // _context.Add(Attachment); _context.SaveChanges(); IEnumerable <Attachments> at = _context.attachments.AsEnumerable(); List <mAttachments> newat = new List <mAttachments>(); foreach (Attachments attachment in at) { if (attachment.noteID == n.noteID) { mAttachments m = new mAttachments(); m.AID = attachment.AID; m.url = attachment.url; newat.Add(m); } } string Json = JsonConvert.SerializeObject(notes, Formatting.Indented); return(StatusCode(201, new{ noteId = notes.noteID, content = n.content, created_on = DateTime.Now, title = n.title, last_updated_on = DateTime.Now, attachments = att })); } else { var conflict = "Bad Request"; return(StatusCode(409, new{ result = conflict })); } }
public Participant Read(int sampleNo) { try { Init(); var sheet = workbook.GetSheetAt(0); Participant.Id Id = new Participant.Id(); Participant.PhysicalAddress physicalAddress = new PhysicalAddress(); Participant.PostalAddress postalAddress = new PostalAddress(); Participant.Contacts contacts = new Contacts(); Participant.ExternalSystemsReferences externalSystemsReferences = new ExternalSystemsReferences(); Participant.NOTES notes = new NOTES(); Participant.BankingDetails bankingDetails = new BankingDetails(); Participant.Conventions conventions = new Conventions(); Participant.BillingPracticeDetails billingPracticeDetails = new BillingPracticeDetails(); Participant.PenaltyGracePeriod penaltyGracePeriod = new PenaltyGracePeriod(); Participant.PenaltyGracePeriodforGuarantor penaltyGracePeriodforGuarantor = new PenaltyGracePeriodforGuarantor(); Participant.BusinessDayConvention businessDayConvention = new BusinessDayConvention(); Participant.IssuerPractices issuerPractices = new IssuerPractices(); Participant.LimitsandRatings limitsandRatings = new LimitsandRatings(); Participant.CreditLimit creditLimit = new CreditLimit(); Participant.CreditRatings creditRatings = new CreditRatings(); foreach (IRow row in sheet) { var attrib = row.GetCell(1).StringCellValue.ToUpper(); var value = GetUnformattedValue(row.GetCell(2 + sampleNo)); switch (row.GetCell(1).StringCellValue.ToUpper()) { case "IDENTIFICATION": if (attrib == "NAME") { Id.Name = value; } else if (attrib == "COUNTRY OF RESIDENCE") { Id.CountryOfResidence = value; } else if (attrib == "COUNTRY OF DOMICILE") { Id.CountryOfDomicile = value; } else if (attrib == "RESIDENCY") { Id.Residency = value; } else if (attrib == "ROLE") { Id.Role = value; } else if (attrib == "CATEGORY") { Id.Category = value; } else if (attrib == "NATIONALSECTOR") { Id.NationalSector = value; } else if (attrib == "INSTTITUTINALSECTOR") { Id.InsttitutinalSector = value; } else if (attrib == "PARENTCOMPANY") { Id.ParentCompany = value; } else if (attrib == "STATUS") { Id.Status = value; } else if (attrib == "PARTICIPANTNOTUSED") { Id.ParticipantNotUsed = value; } else if (attrib == "PARTICIPANTISOWNER") { Id.ParticipantIsOwner = value; } else if (attrib == "EXPORTCODE") { Id.ExportCode = value; } else if (attrib == "EXTERNALCODE") { Id.ExternalCode = value; } break; case "PHYSICAL ADDRESS": if (attrib == "ADDRESSLINE1") { physicalAddress.AddressLine1 = value; } else if (attrib == "ADDRESSLINE2") { physicalAddress.AddressLine2 = value; } else if (attrib == "ADDRESSLINE3") { physicalAddress.AddressLine3 = value; } else if (attrib == "CODE") { physicalAddress.Code = value; } else if (attrib == "COUNTRY") { physicalAddress.Country = value; } else if (attrib == "CITY") { physicalAddress.City = value; } break; case "POSTAL ADDRESS": if (attrib == "ADDRESSLINE1") { postalAddress.AddressLine1 = value; } else if (attrib == "ADDRESSLINE2") { postalAddress.AddressLine2 = value; } else if (attrib == "ADDRESSLINE3") { postalAddress.AddressLine3 = value; } else if (attrib == "CODE") { postalAddress.Code = value; } else if (attrib == "CITY") { postalAddress.City = value; } else if (attrib == "WEBADDRESS") { postalAddress.WebAddress = value; } break; case "CONTACTS": if (attrib == "CONTACTNAME") { contacts.ContactName = value; } else if (attrib == "CONTACTTELEPHONENUMBER") { contacts.ContactTelephoneNumber = value; } else if (attrib == "CONTACTFAXNUMBER") { contacts.ContactFaxNumber = value; } else if (attrib == "CONTACTEMAIL") { contacts.ContactEmail = value; } else if (attrib == "PRIMARYCONTACTINDICATOR") { contacts.PrimaryContactIndicator = value; } break; case "EXTERNAL SYSTEMS REFERENCES": if (attrib == "EXTERNALSYSTEM") { externalSystemsReferences.Externalsystem = value; } else if (attrib == "REFERENCE") { externalSystemsReferences.Reference = value; } break; case "NOTES": if (attrib == "NOTESDATE") { notes.NotesDate = value; } else if (attrib == "NOTES") { notes.Notes = value; } break; case "BANKING DETAILS": if (attrib == "BANKNAME") { bankingDetails.BankName = value; } else if (attrib == "ACCOUNTNAME") { bankingDetails.AccountName = value; } else if (attrib == "CURRENCY") { bankingDetails.Currency = value; } else if (attrib == "IBAN") { bankingDetails.IBAN = value; } else if (attrib == "SWIFTBICNUMBER") { bankingDetails.SWIFTBICNumber = value; } else if (attrib == "COUNTRY") { bankingDetails.Country = value; } else if (attrib == "CITY") { bankingDetails.City = value; } else if (attrib == "STARTDATE") { bankingDetails.StartDate = value; } else if (attrib == "ENDDATE") { bankingDetails.EndDate = value; } else if (attrib == "ACCOUNTUSE") { bankingDetails.AccountUse = value; } else if (attrib == "BANKACCOUNTSTATUS") { bankingDetails.BankAccountStatus = value; } else if (attrib == "APPLICABLEINSTRUMENTTYPES") { bankingDetails.ApplicableInstrumentTypes = value; } else if (attrib == "DEFAULTDEBITACCOUNT") { bankingDetails.DefaultDebitAccount = value; } else if (attrib == "DEFAULTDEBITSTARTDATE") { bankingDetails.DefaultDebitStartDate = value; } else if (attrib == "DEFAULTDEBITENDDATE") { bankingDetails.DefaultDebitEndDate = value; } else if (attrib == "DEFAULTCREDITACCOUNT") { bankingDetails.DefaultCreditAccount = value; } else if (attrib == "DEFAULTCREDITSTARTDATE") { bankingDetails.DefaultCreditStartDate = value; } else if (attrib == "DEFAULTCREDITENDDATE") { bankingDetails.DefaultCreditEndDate = value; } else if (attrib == "INTERMEDIARYBANKINGDETAILS") { bankingDetails.IntermediaryBankingdetails = value; } break; case "BILLING PRACTICE DETAILS": if (attrib == "OPTIONS") { billingPracticeDetails.Options = value; } else if (attrib == "INTERMEDIARYBANKINGDETAILS") { billingPracticeDetails.Period = value; } break; case "PENALTY GRACE PERIOD": if (attrib == "PERIOD") { penaltyGracePeriod.Period = value; } else if (attrib == "PERIODICITY") { penaltyGracePeriod.Periodicity = value; } break; case "PENALTY GRACE PERIOD (FOR GUARANTOR)": if (attrib == "PERIOD") { penaltyGracePeriodforGuarantor.Period = value; } else if (attrib == "PERIODICITY") { penaltyGracePeriodforGuarantor.Periodicity = value; } else if (attrib == "PAYMENTFREQUENCY") { penaltyGracePeriodforGuarantor.PaymentFrequency = value; } else if (attrib == "EXPECTEDTIMEFORCLAIMSETTLEMENTINDAYS") { penaltyGracePeriodforGuarantor.ExpectedTimeforClaimSettlementindays = value; } else if (attrib == "PAYMENTAPPLICATIONMETHOD") { penaltyGracePeriodforGuarantor.PaymentApplicationMethod = value; } else if (attrib == "MINIMUMBILLAMOUNT") { penaltyGracePeriodforGuarantor.MinimumBillAmount = value; } else if (attrib == "PREPAYMENTMETHODS") { penaltyGracePeriodforGuarantor.Prepaymentmethods = value; } else if (attrib == "LEGALCLAUSES") { penaltyGracePeriodforGuarantor.LegalClauses = value; } break; case "BUSINESS DAY CONVENTION": if (attrib == "CASHFLOWTYPE") { businessDayConvention.CashFlowType = value; } else if (attrib == "DATEROLL") { businessDayConvention.DateRoll = value; } else if (attrib == "CALCULATEARREARSFROM") { businessDayConvention.Calculatearrearsfrom = value; } else if (attrib == "ENDMONTHINDICATOR") { businessDayConvention.EndMonthIndicator = value; } else if (attrib == "INTERESTCALCULATEDTO") { businessDayConvention.InterestCalculatedTo = value; } break; case "ISSUER PRACTICES": if (attrib == "OPTIONS") { issuerPractices.Options = value; } else if (attrib == "BOOKCLOSEDPERIODPERIOD") { issuerPractices.BookClosedPeriodPeriod = value; } else if (attrib == "PERIODICITY") { issuerPractices.Periodicity = value; } break; case "CREDIT LIMIT": if (attrib == "CATEGORY") { creditLimit.Category = value; } else if (attrib == "AMOUNTPERIOD") { creditLimit.AmountPeriod = value; } break; case "CREDIT RATINGS": if (attrib == "RATINGAGENCY") { creditRatings.RatingAgency = value; } else if (attrib == "RATINGDATE") { creditRatings.RatingDate = value; } else if (attrib == "CREDITRATING") { creditRatings.CreditRating = value; } else if (attrib == "RATINGOUTLOOK") { creditRatings.RatingOutlook = value; } else if (attrib == "WATCHDATE") { creditRatings.WatchDate = value; } break; } } participant = new Participant(); participant._Id = Id; //participant._PhysicalAddress = return(participant); } catch (Exception ex) { Console.WriteLine("Error Reading Input Excel file"); throw (ex); } }
public void Add(NOTES note) { context.NOTES.Add(note); context.SaveChanges(); }
public ActionResult createNotes(NOTES n, IFormFile file) { if (ModelState.IsValid) { var authHeader = AuthenticationHeaderValue.Parse(Request.Headers["Authorization"]); var credentialBytes = Convert.FromBase64String(authHeader.Parameter); var credentials = Encoding.UTF8.GetString(credentialBytes).Split(':'); var username = credentials[0]; string fileName = (file.FileName + rand.ToString()); rand++; // var uniqueFileName = GetUniqueFileName(file.FileName); var uploads = Path.Combine(Directory.GetCurrentDirectory(), fileName); var filePath = Path.Combine(uploads); if (file.Length > 0) { using (var stream = new FileStream(filePath, FileMode.Create)) file.CopyToAsync(stream); } var Attachment = new Attachments { url = uploads, FileName = file.FileName, length = file.Length, noteID = n.noteID }; _context.Add(Attachment); mAttachments att = new mAttachments(); att.AID = Attachment.AID; att.url = Attachment.url; _context.SaveChanges(); var notes = new NOTES { EMAIL = username, attachments = Attachment, content = n.content, created_on = DateTime.Now, title = n.title, last_updated_on = DateTime.Now }; _context.Add(notes); // _context.Add(Attachment); _context.SaveChanges(); IEnumerable <Attachments> at = _context.attachments.AsEnumerable(); List <mAttachments> newat = new List <mAttachments>(); foreach (Attachments attachment in at) { if (attachment.noteID == n.noteID) { mAttachments m = new mAttachments(); m.AID = attachment.AID; m.url = attachment.url; newat.Add(m); } } string Json = JsonConvert.SerializeObject(notes, Formatting.Indented); // var a1 = new mAttachments{AID = Attachment.AID ,url=Attachment.url}; // string username = us.getUsername(); return(StatusCode(201, new{ noteId = notes.noteID, content = n.content, created_on = DateTime.Now, title = n.title, last_updated_on = DateTime.Now, attachments = att })); } else { var conflict = "Bad Request"; return(StatusCode(409, new{ result = conflict })); } }
public ActionResult AttachImage(string id, IFormFile file) { var fileTransferUtility = new TransferUtility(s3Client); string fileName = (file.FileName + rand.ToString()); rand++; // var uniqueFileName = GetUniqueFileName(file.FileName); var filePath = Path.Combine(file.FileName); var uploads = Path.Combine(Directory.GetCurrentDirectory(), file.FileName); using (var stream = new FileStream(uploads, FileMode.Create)) { // fileTransferUtility.UploadAsync(stream,bucketName, keyName); file.CopyToAsync(stream); } string username = getUsername(); Console.WriteLine("Upload 1 completed"); if (file.Length > 0) { } NOTES note = _context.notes.Find(id); var Attachment = new Attachments { url = uploads, FileName = file.FileName, length = file.Length, noteID = note.noteID }; _context.Add(Attachment); _context.SaveChanges(); IEnumerable <Attachments> a1 = _context.attachments.AsEnumerable(); List <mAttachments> am = new List <mAttachments>(); foreach (Attachments at in a1) { if (at.noteID == id) { mAttachments mA = new mAttachments(); mA.AID = at.AID; mA.url = at.url; am.Add(mA); } } IEnumerable <mAttachments> newA = am; if (ModelState.IsValid) { var a11 = new mAttachments { AID = Attachment.AID, url = Attachment.url }; // string username = us.getUsername(); return(StatusCode(201, new{ a11 })); } else { var conflict = "Bad Request"; return(StatusCode(409, new{ result = conflict })); } }