コード例 #1
0
        public ActionResult ResetPassword()
        {
            var context = new ExploreMidwestDBContext();

            var userMgr = new UserManager <IdentityUser>(new UserStore <IdentityUser>(context));

            return(RedirectToAction("Login", "Home"));
        }
コード例 #2
0
ファイル: ManagerController.cs プロジェクト: ganzmn/ExploreMW
        public ActionResult AddBlog()
        {
            BlogVM model = new BlogVM()
            {
                BlogCategory = new Category(),
                BlogTags     = new List <Tag>(),
                Author       = User.Identity.Name,
                Date         = DateTime.Today
            };

            var context = new ExploreMidwestDBContext();

            model.SetCategories(context.Category.ToList());

            return(View(model));
        }
コード例 #3
0
ファイル: ManagerController.cs プロジェクト: ganzmn/ExploreMW
        public ActionResult AddBlog(BlogVM b)
        {
            var repo    = BlogRepoFactory.Create();
            var context = new ExploreMidwestDBContext();

            if (ModelState.IsValid)
            {
                Blog blog = new Blog();
                if (b.File != null)
                {
                    string pic  = Path.GetFileName(b.File.FileName);
                    string path = Path.Combine(
                        Server.MapPath("~/images"), pic);
                    // file is uploaded
                    b.File.SaveAs(path);

                    blog = new Blog
                    {
                        BlogId        = b.BlogId,
                        Body          = b.Body,
                        IsDeleted     = b.IsDeleted,
                        IsFinished    = b.IsFinished,
                        BlogTags      = new List <Tag>(),
                        Title         = b.Title,
                        Author        = User.Identity.Name,
                        Date          = DateTime.Now,
                        ImageLocation = "images/" + Path.GetFileName(b.File.FileName),
                    };
                }
                else
                {
                    blog = new Blog
                    {
                        BlogId     = b.BlogId,
                        Body       = b.Body,
                        IsDeleted  = b.IsDeleted,
                        IsFinished = b.IsFinished,
                        BlogTags   = new List <Tag>(),
                        Title      = b.Title,
                        Author     = User.Identity.Name,
                        Date       = DateTime.Now,
                    };
                }
                if (b.BlogCategory.CategoryId == 0)
                {
                    Category c = new Category
                    {
                        CategoryType = b.NewCategory
                    };
                    context.Category.Add(c);
                    context.SaveChanges();
                    blog.BlogCategory = context.Category.FirstOrDefault(g => g.CategoryType == c.CategoryType);
                }
                else
                {
                    blog.BlogCategory = context.Category.FirstOrDefault(c => c.CategoryId == b.BlogCategory.CategoryId);
                }
                repo.AddBlog(blog);
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                b.SetCategories(context.Category.ToList());
                return(View(b));
            }
        }