public ActionResult Edit(int id, string title, string subhead, int advType, string link, HttpPostedFileBase img, int isshow, int priority) { ViewBag.Error = "none"; string imgUrl = ""; if (img != null && img.ContentLength > 0) { UploadFileResult result = img.FileUpLoad("img", 1024 * 1024 * 4, "images"); if (!result.Ok) { ViewBag.Error = result.Data; } else { imgUrl = result.Data; } } MldAdv model = advDal.Query(id); model.AdvType = advType; model.Link = link; model.IsShow = isshow; model.Priority = priority; model.ID = id; model.SubHead = subhead; model.Title = title; if (!string.IsNullOrEmpty(imgUrl)) { model.Img = imgUrl; } if (advDal.Update(model)) { ViewBag.Success = "ok"; } else { ViewBag.Error = "Error"; } return(View(model)); }
public ActionResult Index(string title, string subhead, int advType, string link, HttpPostedFileBase img, int isshow, int priority) { ViewBag.Error = "none"; string imgUrl = ""; if (img != null && img.ContentLength > 0) { UploadFileResult result = img.FileUpLoad("img", 1024 * 1024 * 4, "images"); if (!result.Ok) { ViewBag.Error = result.Data; } else { imgUrl = result.Data; MldAdv model = new MldAdv(); model.AdvType = advType; model.Link = link; model.Img = imgUrl; model.IsShow = isshow; model.Priority = priority; model.Title = title; model.SubHead = subhead; if (advDal.Add(model) > 0) { ViewBag.Success = "ok"; } else { ViewBag.Error = "Error"; } } } else { ViewBag.Error = "Please select the picture to upload"; } return(View()); }