Esempio n. 1
0
        public ActionResult Index()
        {
            var sb = new StringBuilder("Dapper service\n");

            int usersBefore = _repo.GetUsers().Count;

            sb.Append($"Users before: {usersBefore}\n");

            var user = new User
            {
                Age       = 18,
                Email     = "*****@*****.**",
                IsMarried = false,
                Name      = "some123",
                Sex       = "male"
            };

            _repo.Create(user);
            sb.Append($"Create user: {user.Id}\n");

            int usersAfter = _repo.GetUsers().Count;

            sb.Append($"Users after: {usersAfter}\n");

            user.Name = "Username123";
            _repo.Update(user);

            User dbUser = _repo.Get(user.Id);

            sb.Append($"Update user: {dbUser.Name}\n");

            _repo.Delete(dbUser.Id);
            sb.Append("Delete user\n");

            int usersAfterDel = _repo.GetUsers().Count;

            sb.Append($"Users after delete: {usersAfterDel}\n");

            return(Content(sb.ToString()));
        }