Exemplo n.º 1
0
        public ActionResult Create(ImageModel model)
        {
            ImageDto dto = new ImageDto();

                dto.ImageTitle = model.ImageTitle;
                if (String.IsNullOrEmpty(model.ImageUrl))
                {
                    ViewBag.status = "Error";
                    ViewBag.msg = "图片不能为空";
                    DataTable dt = CMSService.SelectSome("Category", "CMSCategory", "CategoryParentId=6");
                    List<SelectListItem> items = new List<SelectListItem>();
                    //List<CategoryDto> list = new List<CategoryDto>();
                    foreach (DataRow dr in dt.Rows)
                    {
                        CategoryDto categoryDto = CategoryMapping.getDTO(dr);
                        items.Add(new SelectListItem { Text = categoryDto.CategoryName, Value = categoryDto.CategoryId.ToString() });

                        // list.Add(dto);

                    }
                    ViewData["Category"] = items;
                    return View();
                }
                else
                {
                    dto.ImageUrl = model.ImageUrl;
                }
                dto.ImageHref = model.ImageHref;
                dto.ImageDescription = model.ImageDescription;
                dto.ImageCategory = model.ImageCategory;
                dto.ImageStatus = false;

                string JsonString = JsonHelper.JsonSerializerBySingleData(dto);
                Message msg = CMSService.Insert("Image", JsonString);
                return RedirectTo("/Image/Index", msg.MessageInfo);
        }
Exemplo n.º 2
0
        public ActionResult Edit(ImageModel model)
        {
            ImageDto dto = new ImageDto();
            DataTable dt = CMSService.SelectOne("Image", "CMSImage", "ImageId=" + model.ImageId);
            foreach (DataRow dr in dt.Rows)
            {

                dto = ImageMapping.getDTO(dr);
                dto.ImageId = model.ImageId;
                dto.ImageTitle = model.ImageTitle;
                dto.ImageUrl = model.ImageUrl;
                dto.ImageHref = model.ImageHref;
                dto.ImageCategory = model.ImageCategory;
                dto.ImageDescription = model.ImageDescription;
                dto.ImageStatus = model.ImageStatus;

            }
            string JsonString = JsonHelper.JsonSerializerBySingleData(dto);
            Message msg = CMSService.Update("Image", JsonString);
            // TODO: Add update logic here

            return RedirectToAction("Index");
        }
Exemplo n.º 3
0
 //
 // GET: /Image/Edit/5
 public ActionResult Edit(int id)
 {
     ImageModel model = new ImageModel();
     DataTable dt = CMSService.SelectOne("Image", "CMSImage", "ImageId=" + id);
     foreach (DataRow dr in dt.Rows)
     {
         ImageDto dto = new ImageDto();
         dto = ImageMapping.getDTO(dr);
         model.ImageId = dto.ImageId;
         model.ImageUrl = dto.ImageUrl;
         model.ImageHref = dto.ImageHref;
         model.ImageTitle = dto.ImageTitle;
         model.ImageDescription = dto.ImageDescription;
         model.ImageCategory = dto.ImageCategory;
     }
     ViewData["Category"] = MyService.GetCategorySelectList("CategoryParentId=6");
     return View(model);
 }