Esempio n. 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            NotlaGelUser notlaGelUser = notlaGelUserManager.Find(x => x.Id == id);

            notlaGelUserManager.Delete(notlaGelUser);
            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        public ActionResult EditProfile(NotlaGelUser model, HttpPostedFileBase ProfileImage)
        {
            ModelState.Remove("ModifiedUsername");
            if (ModelState.IsValid)
            {
                if (ProfileImage != null && (ProfileImage.ContentType == "image/jpeg" || ProfileImage.ContentType == "image/jpg" || ProfileImage.ContentType == "image/png"))
                {
                    string filename = $"user_{model.Id}.{ProfileImage.ContentType.Split('/')[1]}";

                    ProfileImage.SaveAs(Server.MapPath($"~/images/{filename}"));
                    model.ProfileImageFilename = filename;
                }

                BusinessLayerResult <NotlaGelUser> res = NotlaGelUserManager.UpdateProfile(model);

                if (res.Errors.Count > 0)
                {
                    ErrorViewModal errorNotifyObj = new ErrorViewModal()
                    {
                        Items          = res.Errors,
                        Title          = "Profil Güncellenemedi.",
                        RedirectingUrl = "/Home/EditProfile"
                    };
                    return(View("Error", errorNotifyObj));
                }
                CurrentSession.Set <NotlaGelUser>("login", res.Result);

                return(RedirectToAction("ShowProfile"));
            }
            return(View(model));
        }
Esempio n. 3
0
        public string GetCurrentUsername()
        {
            NotlaGelUser user = CurrentSession.user;

            if (user != null)
            {
                return(user.UserName);
            }
            else
            {
                return("system");
            }
        }
Esempio n. 4
0
        // GET: NotlaGelUser/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            NotlaGelUser notlaGelUser = notlaGelUserManager.Find(x => x.Id == id.Value);

            if (notlaGelUser == null)
            {
                return(HttpNotFound());
            }
            return(View(notlaGelUser));
        }
Esempio n. 5
0
        public ActionResult Edit(NotlaGelUser notlaGelUser)
        {
            ModelState.Remove("CreatedOn");
            ModelState.Remove("ModifiedOn");
            ModelState.Remove("ModifiedUsername");

            if (ModelState.IsValid)
            {
                BusinessLayerResult <NotlaGelUser> res = notlaGelUserManager.update(notlaGelUser);
                if (res.Errors.Count > 0)
                {
                    res.Errors.ForEach(x => ModelState.AddModelError("", x.Message));
                    return(View(notlaGelUser));
                }

                return(RedirectToAction("Index"));
            }
            return(View(notlaGelUser));
        }
        protected override void Seed(DatabaseContext context)
        {
            NotlaGelUser admin = new NotlaGelUser()
            {
                Name                 = "Metehan",
                SurName              = "Metinoğlu",
                Email                = "*****@*****.**",
                ActivateGuid         = Guid.NewGuid(),
                IsActive             = true,
                IsAdmin              = true,
                UserName             = "******",
                ProfileImageFilename = "img_avatar.png",
                Password             = "******",
                CreatedOn            = DateTime.Now,
                ModifiedOn           = DateTime.Now.AddMinutes(5),
                ModifiedUsername     = "******"
            };
            NotlaGelUser standartuser = new NotlaGelUser()
            {
                Name                 = "Mete",
                SurName              = "Metinoğlu",
                Email                = "*****@*****.**",
                ActivateGuid         = Guid.NewGuid(),
                IsActive             = true,
                IsAdmin              = false,
                UserName             = "******",
                ProfileImageFilename = "img_avatar.png",
                Password             = "******",
                CreatedOn            = DateTime.Now.AddHours(1),
                ModifiedOn           = DateTime.Now.AddMinutes(5),
                ModifiedUsername     = "******"
            };

            context.NotlaGelUsers.Add(admin);
            context.NotlaGelUsers.Add(standartuser);

            for (int i = 0; i < 8; i++)
            {
                NotlaGelUser user = new NotlaGelUser()
                {
                    Name                 = FakeData.NameData.GetFirstName(),
                    SurName              = FakeData.NameData.GetSurname(),
                    Email                = FakeData.NetworkData.GetEmail(),
                    ActivateGuid         = Guid.NewGuid(),
                    IsActive             = true,
                    IsAdmin              = false,
                    UserName             = $"user{i}",
                    ProfileImageFilename = "img_avatar.png",
                    Password             = "******",
                    CreatedOn            = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                    ModifiedOn           = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                    ModifiedUsername     = $"user{i}"
                };
                context.NotlaGelUsers.Add(user);
            }
            context.SaveChanges();

            List <NotlaGelUser> userlist = context.NotlaGelUsers.ToList();

            //fake kategori ekleme
            for (int i = 0; i < 10; i++)
            {
                Category cat = new Category()
                {
                    Title            = FakeData.PlaceData.GetStreetName(),
                    Description      = FakeData.PlaceData.GetAddress(),
                    CreatedOn        = DateTime.Now,
                    ModifiedOn       = DateTime.Now,
                    ModifiedUsername = "******"
                };

                context.Categories.Add(cat);

                //Not ekleme
                for (int k = 0; k < FakeData.NumberData.GetNumber(5, 9); k++)
                {
                    NotlaGelUser owner = userlist[FakeData.NumberData.GetNumber(0, userlist.Count - 1)];
                    Note         note  = new Note()
                    {
                        Title            = FakeData.TextData.GetAlphabetical(FakeData.NumberData.GetNumber(5, 25)),
                        Text             = FakeData.TextData.GetSentences(FakeData.NumberData.GetNumber(1, 3)),
                        IsDraft          = false,
                        LikeCount        = FakeData.NumberData.GetNumber(1, 9),
                        Owner            = owner,
                        CreatedOn        = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                        ModifiedOn       = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                        ModifiedUsername = owner.UserName
                    };
                    cat.Notes.Add(note);

                    //yorum ekleme
                    for (int j = 0; j < FakeData.NumberData.GetNumber(3, 5); j++)
                    {
                        NotlaGelUser comment_owner = userlist[FakeData.NumberData.GetNumber(0, userlist.Count - 1)];


                        Comment comment = new Comment()
                        {
                            Text             = FakeData.TextData.GetSentence(),
                            Owner            = comment_owner,
                            CreatedOn        = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                            ModifiedOn       = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now),
                            ModifiedUsername = comment_owner.UserName
                        };
                        note.Comments.Add(comment);
                    }

                    //like ekleme


                    for (int m = 0; m < note.LikeCount; m++)
                    {
                        Liked liked = new Liked()
                        {
                            LikedUser = userlist[m]
                        };
                        note.Likes.Add(liked);
                    }
                }
            }
            context.SaveChanges();
        }