Пример #1
0
        /// <summary>
        /// 添加每日发现电影
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static string Create(ManageDiscViewModel model)
        {
            using (MR_DataClassesDataContext _db = new MR_DataClassesDataContext())
            {
                tbl_Discovery disc = new tbl_Discovery()
                {
                    disc_Movie = model.Movie,
                    disc_Image = model.Image
                };

                string guid;
                do
                {
                    guid = Guid.NewGuid().ToString("N").ToUpper();
                } while (_db.tbl_Discovery.Where(p => p.disc_Id == guid).Count() != 0);
                disc.disc_Id   = guid;
                disc.disc_Flag = _db.tbl_Discovery.OrderByDescending(d => d.disc_Flag).ToList()[0].disc_Flag + 1;

                _db.tbl_Discovery.InsertOnSubmit(disc);
                _db.SubmitChanges();
                _db.SetDiscTime(guid);

                return(disc.disc_Id);
            }
        }
Пример #2
0
 public ActionResult Create(ManageDiscViewModel model, System.Web.HttpPostedFileBase file)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     if (!MovieManager.Exist(model.Movie))
     {
         ModelState.AddModelError("", "输入的电影不存在,请输入正确的电影编号");
         return(View());
     }
     if (file != null && file.ContentLength > 0)
     {
         var fileName = System.IO.Path.Combine(Request.MapPath("~/Content/Discovery/"), System.IO.Path.GetFileName(file.FileName));
         file.SaveAs(fileName);
         model.Image = System.IO.Path.GetFileName(file.FileName);
     }
     DiscManager.Create(model);
     return(RedirectToAction("Index"));
 }