public ActionResult Upload(string c, string t, string k, string d, string isShow, string isTop, string urls) { if (Session["UserId"] == null) { return Redirect("/admin/"); } UploadModel model = new UploadModel(); model.CategoryList = categoryService.GetCategories("album"); model.isSuccessful = "添加失败"; model.SelectedCategory = c; if (!string.IsNullOrEmpty(c) && !string.IsNullOrEmpty(t) && !string.IsNullOrEmpty(k) && !string.IsNullOrEmpty(d) && !string.IsNullOrEmpty(urls)) { Album album = new Album(); album.CategoryId = c; album.Title = t; album.Keywords = k; album.Description = d; album.IsDelete = false; album.IsShow = false; album.IsTop = false; album.InsertTime = DateTime.Now; album.ViewTime = 0; if (!string.IsNullOrEmpty(isShow) && isShow == "true") { album.IsShow = true; } if (!string.IsNullOrEmpty(isTop) && isTop == "true") { album.IsTop = true; } urls = urls.Substring(0, urls.Length); string[] us = urls.Split('|'); List<Image> images = new List<Image>(); foreach (var original in us) { if (original.Contains(".jpg") || original.Contains(".png") || original.Contains(".gif")) { string imageName = original.Substring(0, original.Length - 4); string filetrype = original.Substring(original.Length - 4, 4); Model.Image image = new Model.Image(); image.UrlOriginal = original; image.UrlThumbnailWidth102x102 = imageName + "-102x102" + filetrype; image.UrlThumbnailWidth235x350 = imageName + "-235x350" + filetrype; image.UrlThumbnailWidth490x350 = imageName + "-490x350" + filetrype; image.UrlThumbnailHeight200 = imageName + "-big" + filetrype; images.Add(image); } } if (albumService.AddAlbum(album, images)) { model.isSuccessful = "添加成功"; } } return View(model); }
public ActionResult Upload() { if (Session["UserId"] == null) { return Redirect("/admin/"); } UploadModel model = new UploadModel(); model.CategoryList = categoryService.GetCategories("album"); model.isSuccessful = ""; model.SelectedCategory = "xinggan"; return View(model); }