public ActionResult Edit(ENote model)
        {
            ModelState.Remove("ModifiedUser");
            ModelState.Remove("ModifiedOn");
            ModelState.Remove("CreateOn");

            if (ModelState.IsValid)
            {
                ENote note = noteManager.Find(x => x.Id == model.Id);
                if (note != null)
                {
                    note.CategoryId = model.CategoryId;
                    note.Title      = model.Title;
                    note.Text       = model.Text;
                    note.IsDraft    = model.IsDraft;
                    if (noteManager.Update(note) == 0)
                    {
                        ModelState.AddModelError("", "DataBaseError!");
                        return(View(model));
                    }
                    return(RedirectToAction("Index", "Note"));
                }
                ModelState.AddModelError("dbNot", "DataBaseError!");
                return(View(model));
            }

            ViewBag.CategoryId = new SelectList(CacheManager.GetCategoriesFromCache(), "Id", "Title", model.CategoryId);
            return(View(model));
        }
Beispiel #2
0
 public Note(ENote aNote, int aOctave, ENoteValue aNoteValue,
             EAccidental aAccidental)
 {
     NoteName   = aNote;
     Eighth     = aOctave;
     NoteValue  = aNoteValue;
     Accidental = aAccidental;
 }
        /// <summary>
        /// Método para gerar a nota
        /// </summary>
        public void GenerateNote()
        {
            if (Pixel == null || Pixel == Color.Empty)
            {
                throw new Exception("Não foi possível gerar a nota");
            }

            _Note = Common.General.Utils.GetColorNote(Pixel);
        }
        public ActionResult Create(ENote model)
        {
            ModelState.Remove("ModifiedUser");
            ModelState.Remove("ModifiedOn");
            ModelState.Remove("CreateOn");

            if (ModelState.IsValid)
            {
                model.Owner = SessionManager.User;
                noteManager.Insert(model);
                return(RedirectToAction("Index", "Note"));
            }

            ViewBag.CategoryId = new SelectList(CacheManager.GetCategoriesFromCache(), "Id", "Title", model.CategoryId);
            return(View(model));
        }
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ENote note = noteManager.Find(x => x.Id == id.Value);

            if (note == null)
            {
                return(new HttpNotFoundResult());
            }

            return(View(note));
        }
        public ActionResult GetNoteText(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ENote note = noteManager.Find(x => x.Id == id);

            if (note == null)
            {
                return(HttpNotFound());
            }

            return(PartialView("_PartialNoteText", note));
        }
Beispiel #7
0
        public void CommnetTest()
        {
            EUser user = repoUser.Find(x => x.Id == 1);
            ENote note = repoNote.Find(x => x.Id == 3);

            EComment comment = new EComment()
            {
                Text         = "Deneme Yorumu",
                CreateOn     = DateTime.Now,
                ModifiedOn   = DateTime.Now,
                ModifiedUser = "******",
                Note         = note,
                Owner        = user,
            };
            int a = repoComment.Insert(comment);
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ENote note = noteManager.Find(x => x.Id == id.Value);

            if (note == null)
            {
                return(new HttpNotFoundResult());
            }

            ViewBag.CategoryId = new SelectList(CacheManager.GetCategoriesFromCache(), "Id", "Title", note.CategoryId);
            return(View(note));
        }
        public ActionResult SetLikes(int noteId, bool liked)
        {
            int res = 0;

            if (SessionManager.User == null)
            {
                return(Json(new { hasErrorr = true, errorMessagee = "You must entry in system for to like.", ress = 0 }));
            }
            ELiked like = likeManager.Find(x => x.Note.Id == noteId && x.LikedUser.Id == SessionManager.User.Id);

            ENote note = noteManager.Find(x => x.Id == noteId);

            if (like != null && liked == false)
            {
                res = likeManager.Delete(like);
            }
            else if (like == null && liked == true)
            {
                res = likeManager.Insert(new ELiked()
                {
                    LikedUser = SessionManager.User,
                    Note      = note
                });
            }

            if (res > 0)
            {
                if (liked)
                {
                    note.LikeCount++;
                }
                else
                {
                    note.LikeCount--;
                }


                res = noteManager.Update(note);

                return(Json(new { hasErrorr = false, errorMessagee = string.Empty, ress = note.LikeCount }));
            }

            return(Json(new { hasErrorr = true, errorMessagee = "Failed.", ress = note.LikeCount }));
        }
Beispiel #10
0
        public ActionResult Create(string text, int?noteId)
        {
            ModelState.Remove("CreateOn");
            ModelState.Remove("ModifiedOn");
            ModelState.Remove("ModifiedUser");

            if (ModelState.IsValid)
            {
                if (noteId == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                ENote note = noteManager.Find(x => x.Id == noteId);

                if (note == null)
                {
                    return(new HttpNotFoundResult());
                }
                if (text == "")
                {
                    return(new HttpNotFoundResult());
                }
                EComment comment = new EComment();
                comment.Text  = text;
                comment.Note  = note;
                comment.Owner = SessionManager.User;

                if (commentManager.Insert(comment) > 0)
                {
                    return(Json(new { ress = true }, JsonRequestBehavior.AllowGet));
                }
            }

            return(Json(new { ress = false }, JsonRequestBehavior.AllowGet));
        }
Beispiel #11
0
 public Note(ENote note = ENote.C, int octave = 4)
 {
     this.note   = ((int)note) + octave * OCTAVE_NOTES;
     this.enote  = note;
     this.octave = octave;
 }
Beispiel #12
0
 public Note(ENote aNote, int aOctave, ENoteValue aNoteValue,
             EAccidental aAccidental, EDotType aDotType) : this(aNote, aOctave, aNoteValue, aAccidental)
 {
     DotType = aDotType;
 }
 public int GetInterval(ENote aNote, ENote anotherNote)
 {
     throw new NotImplementedException();
 }
 private ENote GetRealNote(ENote aNote)
 {
     throw new NotImplementedException();
 }
Beispiel #15
0
        protected override void Seed(DatabaseContext context)
        {
            EUser admin = new EUser()
            {
                Name                 = "Sinan",
                Surname              = "Tok",
                Email                = "*****@*****.**",
                ActiveGuid           = Guid.NewGuid(),
                IsActive             = true,
                IsAdmin              = true,
                Username             = "******",
                Password             = "******",
                ProfileImageFileName = "user.jpg",
                CreateOn             = DateTime.Now,
                ModifiedOn           = DateTime.Now.AddMinutes(5),
                ModifiedUser         = "******"
            };

            EUser standartUser = new EUser()
            {
                Name         = "tok",
                Surname      = "Tok",
                Email        = "*****@*****.**",
                ActiveGuid   = Guid.NewGuid(),
                IsActive     = true,
                IsAdmin      = false,
                Username     = "******",
                Password     = "******",
                CreateOn     = DateTime.Now.AddHours(1),
                ModifiedOn   = DateTime.Now.AddMinutes(5),
                ModifiedUser = "******"
            };

            context.EUsers.Add(admin);
            context.EUsers.Add(standartUser);

            for (int h = 0; h < 8; h++)
            {
                EUser user = new EUser()
                {
                    Name         = FakeData.NameData.GetFirstName(),
                    Surname      = FakeData.NameData.GetSurname(),
                    Email        = FakeData.NetworkData.GetEmail(),
                    ActiveGuid   = Guid.NewGuid(),
                    IsActive     = true,
                    IsAdmin      = false,
                    Username     = $"user{h}",
                    Password     = "******",
                    CreateOn     = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                    ModifiedOn   = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                    ModifiedUser = $"user{h}",
                };

                context.EUsers.Add(user);
            }

            context.SaveChanges();

            //user list for using..
            List <EUser> userlist = context.EUsers.ToList();

            //adding fake categories
            for (int i = 0; i < 10; i++)
            {
                ECategory cat = new ECategory()
                {
                    Title        = FakeData.PlaceData.GetStreetName(),
                    Description  = FakeData.PlaceData.GetAddress(),
                    CreateOn     = DateTime.Now,
                    ModifiedOn   = DateTime.Now,
                    ModifiedUser = "******",
                };

                context.ECategories.Add(cat);

                //adding fake notes
                for (int k = 0; k < FakeData.NumberData.GetNumber(5, 9); k++)
                {
                    EUser owner = userlist[FakeData.NumberData.GetNumber(0, userlist.Count - 1)];

                    ENote note = new ENote()
                    {
                        Title        = FakeData.TextData.GetAlphabetical(FakeData.NumberData.GetNumber(5, 25)),
                        Text         = FakeData.TextData.GetSentences(FakeData.NumberData.GetNumber(1, 3)),
                        Category     = cat,
                        IsDraft      = false,
                        LikeCount    = FakeData.NumberData.GetNumber(1, 9),
                        Owner        = owner,
                        CreateOn     = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                        ModifiedOn   = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                        ModifiedUser = owner.Username,
                    };

                    cat.Notes.Add(note);


                    //adding fake comments
                    for (int j = 0; j < FakeData.NumberData.GetNumber(3, 5); j++)
                    {
                        EUser commnentOwner = userlist[FakeData.NumberData.GetNumber(0, userlist.Count - 1)];

                        EComment comment = new EComment()
                        {
                            Text         = FakeData.TextData.GetSentence(),
                            Owner        = commnentOwner,
                            CreateOn     = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                            ModifiedOn   = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                            ModifiedUser = commnentOwner.Username,
                        };

                        note.Comments.Add(comment);
                    }

                    //adding fake likes

                    for (int p = 0; p < note.LikeCount; p++)
                    {
                        ELiked like = new ELiked()
                        {
                            LikedUser = userlist[p]
                        };

                        note.Likes.Add(like);
                    }
                }
            }

            context.SaveChanges();
        }