/// <summary> /// Deletes a <see cref="Note"/> object /// </summary> /// <param name="note"></param> public void Delete(Note note) { using (var repo = new NotesRepository()) { repo.Delete(note); } }
public List <Note> GetNotesFromFile() { NotesRepository notesRepository = new NotesRepository(); NotesRepository.SetPath(pathGet); return(notesRepository.GetNotes()); }
public ActionResult Unpublish(int NoteID) { if (Session["UserID"] == null) { return(RedirectToAction("Login", "Authentication", new { ReturnUrl = @"/Admin/NoteActions/" + NoteID + "/Approve" })); } int UserID = Convert.ToInt32(User.Identity.Name); NoteModel Note = NotesRepository.GetNoteDetailsById(NoteID); if (Note == null ? true : Note.Status != 3) { return(new HttpStatusCodeResult(System.Net.HttpStatusCode.NotFound)); } RejectNoteModel Rn = new RejectNoteModel() { NoteID = NoteID, NoteCategory = Note.Category, NoteTitle = Note.Title }; return(PartialView("~/Views/Admin/NoteViews/_UnpublishNotePopup.cshtml", Rn)); }
/// <summary> /// Gets a list of <see cref="Note"/> objects based on note type /// </summary> /// <param name="noteTypeId"></param> /// <returns></returns> public IEnumerable <Note> GetAllByType(int noteTypeId) { using (var repo = new NotesRepository()) { return(repo.GetAllByType(noteTypeId)); } }
public void ShouldCreateNote() { //arrange var Categ = new CategoriesRepository(_connectionstring).Create(new Category() { Name = "TestCategory", Id = Guid.NewGuid() }); var GuidCreator = new UsersRepository(_connectionstring).Create(new ApplicationUser() { UserName = "******", Password = string.Empty }).Id_; var GuidCategory = Categ.Id; UsersForTests.Add(GuidCreator); CategoriesForTests.Add(GuidCategory); var note = new Note() { Title = "TestNote", Text = "TestText", Creator = GuidCreator, Category = GuidCategory, Id = Guid.NewGuid() }; var repository = new NotesRepository(_connectionstring); //act var CreatedNote = repository.Create(note); NotesForTests.Add(CreatedNote.Id); var NoteFromDB = repository.GetNote(CreatedNote.Id); //assert Assert.AreEqual(CreatedNote.Id, NoteFromDB.Id); }
public void Validations() { var filename = $"TestFile {DateTime.UtcNow.ToString("o").Replace(":", string.Empty).Replace("-", string.Empty)}.test"; NotesRepository repository = new NotesRepository(filename); Assert.ThrowsException <InvalidOperationException>(() => _ = repository.LoadNotes()); }
public AuthorGraphType(NotesRepository notes) { _notes = notes; this.Name = "Author"; this.Description = "Represents someone who has manipulated a note."; Field <NonNullGraphType <IdGraphType> >( name: "id", description: "A globally unique identifier for the author.", resolve: _ => IdPrefix + _.Source.Id); Field <StringGraphType>( name: "userName", description: "The user name of the author.", resolve: _ => _.Source.UserName); Field <StringGraphType>( name: "fullName", description: "The fully qualified name of the author.", resolve: _ => GetFullName(_.Source)); Field <StringGraphType>( name: "email", description: "The email address of the author.", resolve: _ => _.Source.Email); FieldAsync <NonNullGraphType <ListGraphType <NonNullGraphType <NoteGraphType> > > >( name: "editedNotes", description: "The notes this author either created or has contributed to.", resolve: async _ => await GetNotesManipulatedBy(_.Source)); }
public ActionResult SearchNotes() { ViewBag.Title = "SearchNotes"; if (Request.IsAuthenticated && Session["UserID"] == null) { return(RedirectToAction("Login", "Authentication")); } else if (Request.IsAuthenticated) { ViewBag.Authorized = true; } SearchNotesModel FilterData = new SearchNotesModel(); FilterData.Type = NotesFilters.Types(); FilterData.Category = NotesFilters.Categories(); FilterData.Country = NotesFilters.Countries(); FilterData.Rating = NotesFilters.Ratings(); FilterData.University = NotesFilters.Universities(); FilterData.Course = NotesFilters.Courses(); ViewBag.FilterData = FilterData; ListNotes Ln = NotesRepository.GetAllAvailableNotes(new NoteModel() { IsItSearchAndFilter = false }); ViewBag.LoadAjaxJS = true; ViewBag.NotesData = Ln; return(View()); }
public ActionResult SearchNotes(NoteModel Nm) { Nm.IsItSearchAndFilter = true; ListNotes Ln = NotesRepository.GetAllAvailableNotes(Nm); return(PartialView("_ListNotes", Ln)); }
public void AddNote(string note) { NotesRepository notesRepository = new NotesRepository(); NotesRepository.SetPath(pathAdd); notesRepository.AddNote(note); }
/// <summary> /// Deletes a <see cref="Note"/> object /// </summary> /// <param name="id"></param> public void Delete(int id) { using (var repo = new NotesRepository()) { repo.Delete(id); } }
/// <summary> /// Get a list of <see cref="Note"/> object for a given content id and property id and user id /// </summary> /// <param name="contentId"></param> /// <param name="propertyTypeId"></param> /// <param name="userId"></param> /// <returns></returns> public IEnumerable <Note> GetAll(int contentId, int propertyTypeId, int userId) { using (var repo = new NotesRepository()) { return(repo.GetAllByContentProp(contentId, propertyTypeId, userId)); } }
/// <summary> /// Get a list of <see cref="Note"/> objects assigned to specific user /// </summary> /// <param name="userId"></param> /// <returns></returns> public IEnumerable <Note> GetAllByAssignee(int userId) { using (var repo = new NotesRepository()) { return(repo.GetAllByAssignee(userId)); } }
/// <summary> /// Get a list of <see cref="Note"/> objects /// </summary> /// <returns></returns> public IEnumerable <Note> GetAll() { using (var repo = new NotesRepository()) { return(repo.GetAll()); } }
/// <summary> /// Get a single <see cref="Note"/> object /// </summary> /// <param name="id"></param> /// <returns></returns> public Note GetById(int id) { using (var repo = new NotesRepository()) { return(repo.Get(id)); } }
/// <summary> /// Get a lis of <see cref="Note"/> objects of a given content node /// </summary> /// <param name="contentId"></param> /// <returns></returns> public IEnumerable <Note> GetAllByContent(int contentId) { using (var repo = new NotesRepository()) { return(repo.GetAllByContent(contentId)); } }
public NotesController(INotesRepository iNotesRepository) { _iNotesRepository = iNotesRepository; NotesRepository notesRepository = new NotesRepository(); notesRepository.OpenFile("CollectionOfNotes\\NoteRepository.json"); }
//public async void updatenote() //{ // String noteId = Intent.GetStringExtra("noteId"); // LoginUser user1 = new LoginUser(); // var uid = user1.User(); // NotesRepository notesRepository = new NotesRepository(); // Note note = await notesRepository.GetNoteByKeyAsync(noteId, uid); // title1.Text = note.Title; // nodes.Text = note.Notes; //} public async override void OnBackPressed() { var noteId = Intent.GetStringExtra("noteId"); NotesRepository notesRepository = new NotesRepository(); if (noteId != null) { LoginUser user1 = new LoginUser(); var uid = user1.User(); Note note = new Note() { Title = title1.Text, Notes = nodes.Text, }; //note.noteType = NoteType.ispin; await notesRepository.UpdateNoteAsync(note, noteId, uid); } else { Note notes = new Note() { Title = title1.Text, Notes = nodes.Text, }; notesRepository.SaveNote(notes); Toast.MakeText(this, "Notes created", ToastLength.Short).Show(); } base.OnBackPressed(); }
public void TestRoundTrip() { var filename = $"TestFile {DateTime.UtcNow.ToString("o").Replace(":", string.Empty).Replace("-", string.Empty)}.test"; var content = Encoding.UTF8.GetBytes("Hello world"); NotesRepository repository = new NotesRepository(filename); try { Assert.IsTrue(repository is INotesRepository); Assert.IsFalse(repository.AreNotesPresent()); Assert.IsFalse(File.Exists(repository.RepositoryFilePath)); repository.SaveNotes(content); Assert.IsTrue(repository.AreNotesPresent()); Assert.IsTrue(File.Exists(repository.RepositoryFilePath)); var readContent = repository.LoadNotes(); var text = Encoding.UTF8.GetString(readContent); Assert.AreEqual("Hello world", text); } finally { if (File.Exists(repository.RepositoryFilePath) == true) { File.Delete(repository.RepositoryFilePath); } } }
public IEnumerable <Note> GetNote() { NotesRepository notesRepository = new NotesRepository(); notesRepository.SetPath(pathGetNote); return(notesRepository.GetNote()); }
public ActionResult Rate(int NoteID) { if (Session["UserID"] == null) { return(RedirectToAction("Login", "Authentication", new { ReturnUrl = @"/RegisteredUser/Downloads" })); } int UserID = Convert.ToInt32(User.Identity.Name); RatingModel Rating = NotesRepository.GetNoteRating(NoteID, UserID); if (Rating == null) { return(PartialView("~/Views/RegisteredUser/_RatingsPopupModal.cshtml", new RatingModel() { NoteID = NoteID })); } else if (Rating.NoteID == -1) { return(new HttpStatusCodeResult(System.Net.HttpStatusCode.Forbidden)); } else { return(PartialView("~/Views/RegisteredUser/_RatingsPopupModal.cshtml", Rating)); } }
public ActionResult Edit(int NoteID) { if (Session["UserID"] == null) { return(RedirectToAction("Login", "Authentication", new { ReturnUrl = @"/NoteActions/Edit/" + NoteID })); } int UserID = Convert.ToInt32(User.Identity.Name); NoteModel Nm = NotesRepository.GetNoteDetailsById(NoteID); if ((Nm.Status != 0) || Nm.SellerID != UserID) { return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest, "You are not allowed to edit this note.")); } SearchNotesModel FilterData = new SearchNotesModel(); FilterData.Type = NotesFilters.Types(); FilterData.Category = NotesFilters.Categories(); FilterData.Country = NotesFilters.Countries(); ViewBag.FilterData = FilterData; ViewBag.Title = "AddNotes"; ViewBag.Authorized = true; ViewBag.LoadValidationScript = true; ViewBag.Edit = true; return(View("~/Views/RegisteredUser/AddNotes.cshtml", Nm)); }
public ActionResult Report(ReportNoteModel Rm) { if (Session["UserID"] == null) { return(RedirectToAction("Login", "Authentication", new { ReturnUrl = @"/RegisteredUser/Downloads" })); } if (!ModelState.IsValid) { return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest)); } int UserID = Convert.ToInt32(User.Identity.Name); if (NotesRepository.SubmitNoteReport(Rm, UserID)) { ViewBag.SellerName = Rm.SellerName; ViewBag.NoteName = Rm.NoteTitle; ViewBag.BuyerName = Session["FullName"]; SendMail.SendEmail(new EmailModel() { EmailTo = SystemConfigData.GetSystemConfigData("AdminEmails").DataValue.Split(';'), EmailSubject = Session["FullName"].ToString() + " reported an issue for " + Rm.NoteTitle, EmailBody = this.getHTMLViewAsString("~/Views/Email/ReportedNote.cshtml") }); return(new HttpStatusCodeResult(System.Net.HttpStatusCode.OK)); } else { return(new HttpStatusCodeResult(System.Net.HttpStatusCode.Forbidden)); } }
public ActionResult Dashboard() { if (Session["UserID"] == null) { return(RedirectToAction("Login", "Authentication", new { ReturnUrl = "/RegisteredUser/Dashboard" })); } //Check if Admin string[] roles = new NotesMarketPlaceRoleManager().GetRolesForUser(User.Identity.Name); if (roles.Contains("SuperAdmin") || roles.Contains("SubAdmin")) { return(RedirectToAction("AdminDashBoard", "Admin")); } int UserID = Convert.ToInt32(User.Identity.Name); var Stats = DownloadRepository.GetUserStats(UserID); DashboardModel DM = new DashboardModel() { NotesSold = Stats.Item1, MoneyEarned = Stats.Item2, Downloads = Stats.Item3, Rejecteds = Stats.Item4, BuyerRequests = Stats.Item5, InProgressNotes = NotesRepository.GetInProgressNotes(UserID), PublishedNotes = NotesRepository.GetPublishedNotes(UserID) }; ViewBag.Title = "Dashboard"; ViewBag.Authorized = true; return(View(DM)); }
protected override void MergeSubItems(Order model) { ItemRepository.MergeList(model.bvin, model.StoreId, model.Items); NotesRepository.MergeList(model.bvin, model.StoreId, model.Notes); CouponRepository.MergeList(model.bvin, model.StoreId, model.Coupons); PackageRepository.MergeList(model.bvin, model.StoreId, model.Packages); ReturnsRepository.MergeList(model.bvin, model.StoreId, model.Returns); }
/// <summary> /// Returns a list of unique content node id's for my tasks /// </summary> /// <param name="userId"></param> /// <returns></returns> public IEnumerable <int> GetUniqueContentNodes(int userId) { using (var repo = new NotesRepository()) { var result = repo.GetUniqueContentNodes(userId); return(result); } }
public PostControllerTest() { var context = new AuthenticationContext(dbContextOptions); DummyDBInitializer db = new DummyDBInitializer(); db.Seed(context); repository = new NotesRepository(context); }
/// <summary> /// Getdatas this instance. /// </summary> public async void Getdata() { var userid = DependencyService.Get <IFirebaseAuthenticator>().User(); NotesRepository notesRepository = new NotesRepository(); List <Note> note = await notesRepository.GetNotesAsync(userid); note = note.Where(a => a.noteType != NoteType.isArchive && a.noteType != NoteType.isTrash).ToList(); this.noteData = note; }
private void resetStorage() { if (File.Exists(storagePath)) { File.Delete(storagePath); } NotesRepository.SetStoragePath(storagePath); notesRepository = new NotesRepository(); }
/// <summary> /// Saves a <see cref="Note"/> object /// </summary> /// <param name="note"></param> public int Save(Note note) { int noteId = -1; using (var repo = new NotesRepository()) { repo.AddOrUpdate(note, out noteId); } return(noteId); }