示例#1
0
        public ActionResult AddQuality(IEnumerable <HttpPostedFileBase> attachments, Quality Qualitymodel, HttpPostedFileBase uploadfile, string txtdate, string Language)
        {
            if (ModelState.IsValid)
            {
                if (uploadfile != null)
                {
                    Random random = new Random();
                    int    rand   = random.Next(1000, 99999999);
                    string path   = rand + Path.GetFileName(uploadfile.FileName);
                    uploadfile.SaveAs(Server.MapPath("~/Content/images/userfiles/news/") + path);
                    Qualitymodel.NewsImage = "/Content/images/userfiles/news/" + path;
                }
                else
                {
                    Qualitymodel.NewsImage = "/Content/images/front/noimage.jpeg";
                }

                //if (Session["ModifiedImageId"] != null)
                //{
                //    string imagename = "/Content/images/userfiles/news/" + Session["ModifiedImageId"].ToString();// + Session["WorkingImageExtension"].ToString();
                //    Qualitymodel.NewsImage = imagename + ".jpeg";
                //    ImageHelperNew.DestroyImageCashAndSession(0,0);

                //    Helpers.ImageHelper.WaterMark(imagename, 100);
                //}
                //else
                //{
                //    Qualitymodel.NewsImage = "/Content/images/front/noimage.jpeg";
                //}

                Qualitymodel.Language    = Language;
                Qualitymodel.TypeId      = 0;
                Qualitymodel.IsMachine   = false;
                Qualitymodel.PageSlug    = Utility.SetPagePlug(Qualitymodel.Header);
                Qualitymodel.TimeCreated = Utility.ControlDateTime(txtdate);
                ViewBag.ProcessMessage   = QualityManager.AddQuality(Qualitymodel);
                Session.Remove("UploadType");
                //foreach (var item in attachments)
                //{
                //    if (item != null && item.ContentLength > 0)
                //    {
                //        Random random = new Random();
                //        int rand = random.Next(1000, 99999999);
                //        new ImageHelper(1024, 768).SaveThumbnail(item, "/Content/images/userfiles/", Utility.SetPagePlug(Qualitymodel.Header) + "_" + rand + Path.GetExtension(item.FileName));
                //        Photo p = new Photo();
                //        p.CategoryId = (int)PhotoType.Quality;
                //        p.ItemId = Qualitymodel.QualityId;
                //        p.Path = "/Content/images/userfiles/" + Utility.SetPagePlug(Qualitymodel.Header) + "_" + rand + Path.GetExtension(item.FileName);
                //        p.Thumbnail = "/Content/images/userfiles/" + Utility.SetPagePlug(Qualitymodel.Header) + "_" + rand + Path.GetExtension(item.FileName);
                //        p.Online = true;
                //        p.SortOrder = 9999;
                //        p.Language = "tr";
                //        p.TimeCreated = DateTime.Now;
                //        p.Title = "Haberler";
                //        PhotoManager.Save(p);
                //    }
                //}
                ModelState.Clear();
                // Response.Redirect("/yonetim/haberduzenle/" + Qualitymodel.QualityId);
                var languages = LanguageManager.GetLanguages();
                var list      = new SelectList(languages, "Culture", "Language");
                ViewBag.LanguageList = list;
                return(View());
            }
            else
            {
                return(View());
            }
        }