コード例 #1
0
ファイル: NoteService.cs プロジェクト: Mivaweb/Notely
 /// <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);
     }
 }
コード例 #2
0
ファイル: MyNotesTests.cs プロジェクト: al-ry/back-end-labs
        public List <Note> GetNotesFromFile()
        {
            NotesRepository notesRepository = new NotesRepository();

            NotesRepository.SetPath(pathGet);
            return(notesRepository.GetNotes());
        }
コード例 #3
0
        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));
        }
コード例 #4
0
ファイル: NoteService.cs プロジェクト: Mivaweb/Notely
 /// <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));
     }
 }
コード例 #5
0
ファイル: UserTest.cs プロジェクト: DenInHub/MyEvernote
        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);
        }
コード例 #6
0
        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());
        }
コード例 #7
0
        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));
        }
コード例 #8
0
        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());
        }
コード例 #9
0
        public ActionResult SearchNotes(NoteModel Nm)
        {
            Nm.IsItSearchAndFilter = true;
            ListNotes Ln = NotesRepository.GetAllAvailableNotes(Nm);

            return(PartialView("_ListNotes", Ln));
        }
コード例 #10
0
ファイル: MyNotesTests.cs プロジェクト: al-ry/back-end-labs
        public void AddNote(string note)
        {
            NotesRepository notesRepository = new NotesRepository();

            NotesRepository.SetPath(pathAdd);
            notesRepository.AddNote(note);
        }
コード例 #11
0
ファイル: NoteService.cs プロジェクト: Mivaweb/Notely
 /// <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);
     }
 }
コード例 #12
0
ファイル: NoteService.cs プロジェクト: Mivaweb/Notely
 /// <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));
     }
 }
コード例 #13
0
ファイル: NoteService.cs プロジェクト: Mivaweb/Notely
 /// <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));
     }
 }
コード例 #14
0
ファイル: NoteService.cs プロジェクト: Mivaweb/Notely
 /// <summary>
 /// Get a list of <see cref="Note"/> objects
 /// </summary>
 /// <returns></returns>
 public IEnumerable <Note> GetAll()
 {
     using (var repo = new NotesRepository())
     {
         return(repo.GetAll());
     }
 }
コード例 #15
0
ファイル: NoteService.cs プロジェクト: Mivaweb/Notely
 /// <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));
     }
 }
コード例 #16
0
ファイル: NoteService.cs プロジェクト: Mivaweb/Notely
 /// <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));
     }
 }
コード例 #17
0
        public NotesController(INotesRepository iNotesRepository)
        {
            _iNotesRepository = iNotesRepository;
            NotesRepository notesRepository = new NotesRepository();

            notesRepository.OpenFile("CollectionOfNotes\\NoteRepository.json");
        }
コード例 #18
0
ファイル: sample.cs プロジェクト: manjubagade/newnativefundoo
        //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();
        }
コード例 #19
0
        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);
                }
            }
        }
コード例 #20
0
        public IEnumerable <Note> GetNote()
        {
            NotesRepository notesRepository = new NotesRepository();

            notesRepository.SetPath(pathGetNote);
            return(notesRepository.GetNote());
        }
コード例 #21
0
        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));
            }
        }
コード例 #22
0
        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));
        }
コード例 #23
0
        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));
            }
        }
コード例 #24
0
        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));
        }
コード例 #25
0
 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);
 }
コード例 #26
0
ファイル: NoteService.cs プロジェクト: Mivaweb/Notely
 /// <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);
     }
 }
コード例 #27
0
        public PostControllerTest()
        {
            var context           = new AuthenticationContext(dbContextOptions);
            DummyDBInitializer db = new DummyDBInitializer();

            db.Seed(context);

            repository = new NotesRepository(context);
        }
コード例 #28
0
        /// <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;
        }
コード例 #29
0
 private void resetStorage()
 {
     if (File.Exists(storagePath))
     {
         File.Delete(storagePath);
     }
     NotesRepository.SetStoragePath(storagePath);
     notesRepository = new NotesRepository();
 }
コード例 #30
0
ファイル: NoteService.cs プロジェクト: Mivaweb/Notely
        /// <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);
        }