예제 #1
0
        public ActionResult Login(Models.User user)
        {
            if (ModelState.IsValid)
            {
                if (user.IsValid(user.UserName, user.Password, _dynamicDb))
                {
                    FormsAuthentication.SetAuthCookie(user.UserName, user.RememberMe);
                    //Emailer.Send( "*****@*****.**", "Test Subject", "Body Sample");
                    //"http://" + Request.Url.Authority + System.Security.Policy.Url .RouteUrl("Default", new {Controller = "User", Action = "Reset"});
                    ContentPage model = new ContentPage
                    {
                        Title = "Successful Login!",
                        Body = "Logged in as " + user.UserName,
                        Link = "http://itotzke.com"
                    };
                    ViewBag.Username = user.UserName;
                    if (Request.IsAjaxRequest())
                    {
                        return PartialView("UserMenu");
                    }
                    else
                    {
                        string dataStr = "Login Successful";

                        ContentPage contentModel = new ContentPage
                        {
                            Title = "Welcome to iTotzke!",
                            Body = dataStr,
                            Link = "http://itotzke.com"
                        };
                        return RedirectToAction("Default", "Home", contentModel);
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Login data is incorrect!");
                }
            }
            //return PartialView("UserMenu", user);
            return View(user);
        }
예제 #2
0
 public ActionResult Default(ContentPage model)
 {
     return View(model);
 }
예제 #3
0
        public ActionResult Register(RegisterNewUser model)
        {
            if (!ModelState.IsValid)
            {
                return View("Register", model);
            }
            else
            {
                if (!model.IsValid(model.UserName, model.Password, model.Email, _dynamicDb))
                {
                    ModelState.AddModelError("", "Login data is incorrect! Username and/or E-mail registered already.");
                    return View("Register", model);
                }
            }

            string dataStr = "";
            dataStr += "User: "******"\n";
            dataStr += "Email: " + model.Email + "\n";

            ContentPage contentModel = new ContentPage
            {
                Title = "Welcome to iTotzke!",
                Body = dataStr,
                Link = "http://itotzke.com"
            };
            return RedirectToAction("Default", "Home", contentModel);
        }
예제 #4
0
        public ActionResult SubmitComment(LessonComment model)
        {
            if (ModelState.IsValid)
            {

                string username = User.Identity.Name;
                User user;
                try
                {
                     user = db.RunProcedure<User>("SelectUserByName", new { UserName = username });
                }
                catch(Exception ex)
                {
                    ModelState.AddModelError("", "Please Login to submit comment.");
                    if (Request.IsAjaxRequest())
                    {
                        return PartialView(model);
                    }
                    else
                    {
                        return View(model);
                    }

                }

                db.RunProcedure<Comment>("InsertComment", new { commentTypeId = model.CommentTypeId, LessonId = model.LessonId, UserId = user.UserId, ParentId = model.ParentId, CommentText = model.CommentText });

                if (Request.IsAjaxRequest())
                {
                    try
                    {
                        model.ParentId = null;
                        model.CommentText = "";

                        List<Comment> comments = db.RunListProcedure<Comment>("[SelectLessonCommentsById]", new { lessonId = model.LessonId });
                        ViewBag.comments = Comment.CreateTree(comments); ;
                        ViewBag.lessonId = model.LessonId;
                        return PartialView("Comments", model);
                    }
                    catch (Exception ex)
                    {

                        return Content(ex.StackTrace);
                    }

                    //return
                }
                else
                {
                    ContentPage contentModel = new ContentPage
                    {
                        Title = "Welcome to iTotzke!",
                        Body = "Post Sucessful.",
                        Link = "http://itotzke.com"
                    };
                    return RedirectToAction("Default", "Home", contentModel);
                }
            }
            if (Request.IsAjaxRequest())
            {
                return PartialView(model);
            }
            return View(model);
        }