Exemplo n.º 1
0
        public ActionResult Create(SliderImgViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {

                    for (var i = 0; i < model.Day; i++)
                    {
                        var topTime = model.StartTime.AddDays(i);
                        SliderImg item = new SliderImg()
                        {
                            AddTime = DateTime.Now,
                            TopTime = topTime,
                            ImgUrl = model.ImgUrl,
                            LinkUrl = model.LinkUrl,
                            MemberID = CookieHelper.MemberID,
                            Status = model.SliderImgStatus,
                            ProvinceCode = model.ProvinceCode,
                            OrderIndex = model.OrderIndex,
                            Title = model.Name
                        };
                        SliderImgService.Create(item);

                    }

                    return RedirectToAction("index");
                }
                catch (Exception ex)
                {
                    return View(model);
                }

            }
            else
            {
                return View(model);
            }
        }
Exemplo n.º 2
0
        public ActionResult Edit(int id)
        {
            var item = SliderImgService.Find(id);

            var model = new SliderImgViewModel();

            //{
            //    StartTime = item.TopTime,
            //    Day = Convert.ToInt32((item.EndTime - item.StartTime).TotalDays),
            //    ImgUrl = item.ImgUrl,
            //    LinkUrl = item.LinkUrl,
            //    OrderIndex = item.OrderIndex,
            //    ProvinceCode = item.ProvinceCode,
            //    Name = item.Title,
            //    SliderImgStatus = item.Status,
            //    ID = item.ID
            //};
            return View(model);
        }
Exemplo n.º 3
0
 public ActionResult Create()
 {
     var model = new SliderImgViewModel();
     return View(model);
 }
Exemplo n.º 4
0
        public ActionResult Edit(SliderImgViewModel model)
        {
            //if (ModelState.IsValid)
            //{
            //    //try
            //    //{
            //    //    SliderImg item = new SliderImg()
            //    //    {
            //    //        ID = model.ID,
            //    //        StartTime = model.StartTime,
            //    //        EndTime = model.StartTime.AddDays(model.Day),
            //    //        ImgUrl = model.ImgUrl,
            //    //        LinkUrl = model.LinkUrl,
            //    //        MemberID = CookieHelper.MemberID,
            //    //        Status = model.SliderImgStatus,
            //    //        ProvinceCode = model.ProvinceCode,
            //    //        OrderIndex = model.OrderIndex,
            //    //        Title = model.Name
            //    //    };

            //    //    SliderImgService.Update(item);

            //    //    return RedirectToAction("index");
            //    //}
            //    //catch (Exception ex)
            //    //{
            //    //    return View(model);
            //    //}
            //}
            //else
            //{
            return View(model);
            //}
        }