예제 #1
0
        public ActionResult Create(BrandGroup model, HttpPostedFileBase fileUpload)
        {
            try
            {
                using (var context = new SiteContainer())
                {
                    var cache = new BrandGroup
                    {
                        Name = SiteHelper.UpdatePageWebName(model.Name),
                        Description = model.Description,
                        SortOrder = model.SortOrder
                    };


                    if (fileUpload != null)
                    {
                        string fileName = IOHelper.GetUniqueFileName("~/Content/Images", fileUpload.FileName);
                        string filePath = Server.MapPath("~/Content/Images");
                        filePath = Path.Combine(filePath, fileName);
                        GraphicsHelper.SaveOriginalImage(filePath, fileName, fileUpload, 500);
                        //fileUpload.SaveAs(filePath);
                        cache.ImageSource = fileName;
                    }

                    context.AddToBrandGroup(cache);

                    var lang = context.Language.FirstOrDefault(p => p.Id == model.CurrentLang);
                    if (lang != null)
                    {
                        CreateOrChangeContentLang(context, model, cache, lang);
                    }

                    return RedirectToAction("Index", "Home", new { area = "BrandCatalogue" });
                }
            }
            catch
            {
                return View();
            }
        }