コード例 #1
0
ファイル: AdminController.cs プロジェクト: hiepbh/Assignment
        public ActionResult SiteInfo(InfoSite info, HttpPostedFileBase image_banner)
        {
            if (ModelState.IsValid)
            {
                ChangeInfoSite ch = new ChangeInfoSite();
                if (image_banner != null && image_banner.ContentLength > 0)
                {
                    string pic = System.IO.Path.GetFileName(image_banner.FileName);
                    string path = System.IO.Path.Combine(Server.MapPath("~/Content/image"), pic);
                    if (System.IO.File.Exists(path))
                    {
                        int count = 2;
                        while (System.IO.File.Exists(path))
                        {
                            pic = count.ToString() + pic;
                            path = System.IO.Path.Combine(Server.MapPath("~/Content/image"), pic);
                        }
                    }
                    image_banner.SaveAs(path);
                    info.imageName = pic;
                    //ch.SaveInfo(info.Address, info.Email, info.Phone, info.Footer, info.imageName);
                }
                ch.SaveInfo(info.Address, info.Email, info.Phone, info.Footer, info.imageName);

                return RedirectToAction("Contact", "Home");
            }
            return View(info);
        }
コード例 #2
0
ファイル: AdminController.cs プロジェクト: hiepbh/Assignment
 public ActionResult SiteInfo()
 {
     InfoSite info = new InfoSite();
     ChangeInfoSite ch = new ChangeInfoSite();
     info.Address = ch.LoadAddress();
     info.Email = ch.LoadEmail();
     info.Phone = ch.LoadPhone();
     info.Footer = ch.LoadFooter();
     info.imageName = ch.LoadBanner();
     return View(info);
 }