Ejemplo n.º 1
0
        public void DeleteTest()
        {
            travelUser user = repo_user.Find(x => x.Username == "xxx");

            if (user != null)
            {
                int result = repo_user.Delete(user);
            }
        }
Ejemplo n.º 2
0
 public string GetCurrentUsername()
 {
     if (HttpContext.Current.Session["login"] != null)
     {
         travelUser user = HttpContext.Current.Session["login"] as travelUser;
         return(user.Username);
     }
     return("system");
 }
Ejemplo n.º 3
0
        public void UpdateTest()
        {
            travelUser user = repo_user.Find(x => x.Username == "aabb");

            if (user != null)
            {
                user.Username = "******";
                int result = repo_user.Update(user);
            }
        }
Ejemplo n.º 4
0
        public ActionResult ShowProfile()
        {
            travelUser        currentUser        = Session["login"] as travelUser;
            travelUserManager eum                = new travelUserManager();
            BusinessLayerResult <travelUser> res = eum.GetUserById(currentUser.Id);

            if (res.Errors.Count > 0)
            {
                //Kullanıcıyı hata ekranına yönlendirme.
            }

            return(View(res.Result));
        }
Ejemplo n.º 5
0
        public BusinessLayerResult <travelUser> RegisterUser(RegisterViewModel data)
        {
            travelUser user = repo_user.Find(x => x.Username == data.Username || x.Email == data.Email);
            BusinessLayerResult <travelUser> res = new BusinessLayerResult <travelUser>();

            if (user != null)
            {
                if (user.Username == data.Username)
                {
                    res.AddError(ErrorMessageCode.usernameAlreadyExists, "Kullanıcı adı kayıtlı.");
                }

                if (user.Email == data.Email)
                {
                    res.AddError(ErrorMessageCode.EmailALreadyExists, "E-posta adresi kayıtlı.");
                }
            }
            else
            {
                int dbResult = repo_user.Insert(new travelUser()
                {
                    Username         = data.Username,
                    Email            = data.Email,
                    Password         = data.Password,
                    ActivateGuid     = Guid.NewGuid(),
                    CreatedOn        = DateTime.Now,
                    ModifiedOn       = DateTime.Now,
                    ModifiedUsername = "******",
                    IsActive         = false,
                    IsAdmin          = false
                });

                if (dbResult > 1)
                {
                    res.Result = repo_user.Find(x => x.Email == data.Email && x.Username == data.Username);
                    //TODO aktivasyon maili atılacak..
                    //layerResult.Result.ActivateGuid

                    string siteUri     = ConfigHelper.Get <string>("SiteRootUri");
                    string activateUri = $"{siteUri}/Home/UserActivate/{res.Result.ActivateGuid}";
                    string body        = $"Merhaba {res.Result.Username};<br><br>Hesabınızı aktifleştirmek için <a href='{activateUri}' target='_blank'>tıklayınız</a>.";
                    MailHelper.SendMail(body, res.Result.Email, "travelWeb Hesap Aktifleştirme");
                }
            }
            return(res);
        }
Ejemplo n.º 6
0
        public void CommentTest()
        {
            travelUser user = repo_user.Find(x => x.Id == 1);
            Note       note = repo_note.Find(x => x.Id == 3);

            Comment comment = new Comment()
            {
                Text             = "Bu bir testtir.",
                CreatedOn        = DateTime.Now,
                ModifiedOn       = DateTime.Now,
                ModifiedUsername = "******",
                Note             = note,
                Owner            = user
            };

            repo_comment.Insert(comment);
        }
Ejemplo n.º 7
0
 public ActionResult EditProfile(travelUser user)
 {
     return(View());
 }
Ejemplo n.º 8
0
        protected override void Seed(DatabaseContext context)
        {
            travelUser admin = new travelUser()
            {
                Name                 = "Deniz",
                Surname              = "Sahin",
                Email                = "*****@*****.**",
                ActivateGuid         = Guid.NewGuid(),
                IsActive             = true,
                IsAdmin              = true,
                Username             = "******",
                ProfileImageFilename = "user.jpg",
                Password             = "******",
                CreatedOn            = DateTime.Now,
                ModifiedOn           = DateTime.Now.AddMinutes(5),
                ModifiedUsername     = "******"
            };

            travelUser standartUser = new travelUser()
            {
                Name                 = "Sarp",
                Surname              = "Erdem",
                Email                = "*****@*****.**",
                ActivateGuid         = Guid.NewGuid(),
                IsActive             = true,
                IsAdmin              = false,
                Username             = "******",
                ProfileImageFilename = "user.jpg",
                Password             = "******",
                CreatedOn            = DateTime.Now.AddHours(1),
                ModifiedOn           = DateTime.Now.AddMinutes(65),
                ModifiedUsername     = "******"
            };

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

            for (int i = 0; i < 8; i++)
            {
                travelUser user = new travelUser()
                {
                    Name    = FakeData.NameData.GetFirstName(),
                    Surname = FakeData.NameData.GetSurname(),
                    Email   = FakeData.NetworkData.GetEmail(),
                    ProfileImageFilename = "user.jpg",
                    ActivateGuid         = Guid.NewGuid(),
                    IsActive             = true,
                    IsAdmin          = false,
                    Username         = $"user{i}",
                    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.travelUsers.Add(user);
            }
            context.SaveChanges();

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

            //adding fake categories...
            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);

                //adding fake notes...
                for (int k = 0; k < FakeData.NumberData.GetNumber(5, 9); k++)
                {
                    travelUser 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            = userlist[FakeData.NumberData.GetNumber(0, userlist.Count - 1)],
                        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);

                    //adding fake comments
                    for (int j = 0; j < FakeData.NumberData.GetNumber(3, 5); j++)
                    {
                        travelUser 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);
                    }

                    //adding fake likes...

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

            context.SaveChanges();
        }