Exemplo n.º 1
0
        protected void BtnPost_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(Title1.Text) && !String.IsNullOrEmpty(Details.Text))
            {
                var db = new ApplicationDbContext();
                db.Posts.Add(new Post()
                {
                    Title   = Title1.Text,
                    Details = Details.Text
                });
                db.SaveChanges();
                var userId = User.Identity.GetUserId();
                var email  = User.Identity.GetUserName();

                // var logService = new LogService();
                // LogService.GetLogs(userId);
                var userLog = new DALUserLog.UserLog
                {
                    UserId      = userId,
                    Action      = "Created",
                    Details     = "A New Post Created",
                    Email       = email,
                    SendingDate = DateTime.UtcNow
                };

                LogService.AddLog(userLog);


                Response.Redirect("/Posts/PostsList");
            }
            ModelState.AddModelError("", "Please Fill All Fields");
        }
Exemplo n.º 2
0
        protected void GridView1_RowDeleted(object sender, GridViewDeletedEventArgs e)
        {
            var userId = User.Identity.GetUserId();
            var email  = User.Identity.GetUserName();

            var userLog = new DALUserLog.UserLog
            {
                UserId      = userId,
                Action      = "Deleted",
                Details     = "Post deleted ",
                Email       = email,
                SendingDate = DateTime.UtcNow
            };

            LogService.AddLog(userLog);
        }
Exemplo n.º 3
0
 public static UserLog UpdateLog(UserLog userLog)
 {
     _db.UserLogs.AddOrUpdate(userLog);
     _db.SaveChanges();
     return(userLog);
 }
Exemplo n.º 4
0
 public static UserLog AddLog(UserLog userLog)
 {
     _db.UserLogs.Add(userLog);
     _db.SaveChanges();
     return(userLog);
 }