Example #1
0
        public ActionResult CustomCreate(FormCollection form, HttpPostedFileBase files)
        {
            using (var context = new SiteContainer())
            {
                if (files!=null)
                {
                    var product = new Product();
                    TryUpdateModel(product, new[] { "SortOrder"});
                    product.Description = HttpUtility.HtmlDecode(form["Description"]);

                    string fileName = IOHelper.GetUniqueFileName("~/Content/Images", files.FileName);
                    string filePath = Server.MapPath("~/Content/Images");
                    filePath = Path.Combine(filePath, fileName);
                    GraphicsHelper.SaveOriginalImage(filePath, fileName, files, 1200);
                    product.ImageSource = fileName;

                    fileName = IOHelper.GetUniqueFileName("~/Content/Images", files.FileName);
                    filePath = Server.MapPath("~/Content/Images");
                    filePath = Path.Combine(filePath, fileName);
                    int x1 = Convert.ToInt32(form["x1"]);
                    int y1 = Convert.ToInt32(form["y1"]);
                    int w = Convert.ToInt32(form["w"]);
                    int h = Convert.ToInt32(form["h"]);
                    
                    GraphicsHelper.SaveCropPreview(filePath, fileName, files, x1, y1, w, h);
                    product.PreviewImageSource = fileName;


                    context.AddToProduct(product);
                    context.SaveChanges();
                }
            }
            return RedirectToAction("Index", "Home", new { area = "", id = "gallery" });
        }
Example #2
0
        public OrderModel(SiteContainer context, int? orderId)
        {
            Title = HttpUtility.HtmlDecode("Я — ЭГО");

            var contents = context.Content.ToList();
            Menu = new Menu();
            foreach (var content in contents)
            {
                Menu.Add(new MenuItem
                {
                    ContentId = content.Id,
                    ContentName = content.Name,
                    Selected = false,
                    SortOrder = content.SortOrder,
                    Title = content.Title
                });
            }

            if (orderId.HasValue)
            {
                Order = context.Order.First(o => o.Id == orderId);
            }
            else
            {
                Orders = context.Order.ToList();
            }
        }
Example #3
0
        public ActionResult Create(FormCollection collection, HttpPostedFileBase fileUpload, HttpPostedFileBase previewFileUpload)
        {
            using (var context = new SiteContainer())
            {
                if (fileUpload != null && previewFileUpload != null)
                {
                    var product = new Product();

                    TryUpdateModel(product, new[] { "SortOrder" });
                    product.Description = HttpUtility.HtmlDecode(collection["Description"]);

                    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);
                    product.ImageSource = fileName;

                    fileName = IOHelper.GetUniqueFileName("~/Content/Images", previewFileUpload.FileName);
                    filePath = Server.MapPath("~/Content/Images");
                    filePath = Path.Combine(filePath, fileName);
                    GraphicsHelper.SaveOriginalImage(filePath, fileName, previewFileUpload, 500);
                    product.PreviewImageSource = fileName;

                    context.AddToProduct(product);

                    context.SaveChanges();
                }

                return RedirectToAction("Index", "Home", new { area = "", id = "gallery" });
            }
        }
Example #4
0
        public ActionResult Order(FormCollection form)
        {
            using (var context = new SiteContainer())
            {
                var order = new Order {Date = DateTime.Now};
                TryUpdateModel(order, new[] {"ProductId", "ProductImageSource", "Name", "Email", "Phone", "Description","Size"});
                context.AddToOrder(order);
                context.SaveChanges();

                string defaultMailAddressFrom = ConfigurationManager.AppSettings["feedbackEmailFrom"];
                string defaultMailAddresses = ConfigurationManager.AppSettings["feedbackEmailsTo"];

                var emailFrom = new MailAddress(defaultMailAddressFrom, "Студия Евгения Миллера");

                var emailsTo = defaultMailAddresses
                    .Split(new[] { ";", " ", "," }, StringSplitOptions.RemoveEmptyEntries)
                    .Select(s => new MailAddress(s))
                    .ToList();

                var result = Helpers.MailHelper.SendTemplate(emailFrom, emailsTo, "Я - Эго. Форма заказа", "FeedbackTemplate.htm", null, true, form["Name"], form["Email"], form["ProductId"], form["Phone"],order.Id);




                return RedirectToAction("Index", "Home", new {id = "gallery"});
            }
        }
Example #5
0
 public ActionResult CustomCreate()
 {
     using (var context = new SiteContainer())
     {
         int maxSortOrder = context.Product.Max(c => (int?)c.SortOrder) ?? 0;
         return View(new Product { SortOrder = maxSortOrder + 1 });
     }
 }
Example #6
0
 public ActionResult Details(int id)
 {
     using (var context = new SiteContainer())
     {
         var model = new OrderModel(context, id);
         return View(model);
     }
 }
Example #7
0
 public ActionResult ProductDetails(int id)
 {
     using (var context = new SiteContainer())
     {
         var product = context.Product.First(p => p.Id == id);
         return PartialView(new Order {ProductId = product.Id, ProductImageSource = product.ImageSource});
     }
 }
Example #8
0
 public ActionResult Edit(int id)
 {
     using (var context = new SiteContainer())
     {
         var content = context.Content.First(c => c.Id == id);
         return View(content);
     }
 }
Example #9
0
        //
        // GET: /Admin/Order/

        public ActionResult Index()
        {
            using (var context = new SiteContainer())
            {
                var model = new OrderModel(context, null);
                return View(model);
            }
        }
Example #10
0
 public string UpdateProjectImage(int productId)
 {
     using (var context = new SiteContainer())
     {
         var product = context.Product.First(p => p.Id == productId);
         GraphicsHelper.SaveCachedImage("~/Content/Images", product.ImageSource, SiteSettings.GetThumbnail("product"));
         return _descr + product.Description;
     }
 }
Example #11
0
 public ActionResult Delete(int id)
 {
     using (var context = new SiteContainer())
     {
         var order = context.Order.First(o => o.Id == id);
         context.DeleteObject(order);
         context.SaveChanges();
     }
     return RedirectToAction("Index");
 }
Example #12
0
 public ActionResult Edit(int id, FormCollection collection)
 {
     using (var context = new SiteContainer())
     {
         var content = context.Content.First(c => c.Id == id);
         TryUpdateModel(content, new[] {"Title","Sortorder","SeoDescription","SeoKeywords","MainPage"});
         content.Text = HttpUtility.HtmlDecode(collection["Text"]);
         context.SaveChanges();
         return RedirectToAction("Index", "Home", new { area="", id = content.Name });
     }
 }
Example #13
0
 public ActionResult Index(string id, int? page)
 {
     using (var context = new SiteContainer())
     {
         var model = new SiteModel(context, id, page);
         ViewBag.IsHomePage = model.IsHomePage;
         ViewBag.Page = page ?? 0;
         ViewBag.TotalCount = model.TotalProductsCount;
         this.SetSeoContent(model);
         return View(model);
     }
 }
Example #14
0
        public SiteModel(SiteContainer context, string contentId, int? page)
        {
            //Title = HttpUtility.HtmlDecode("Я — ЭГО");

            Content = context.Content.FirstOrDefault(c => c.Name == contentId) ?? context.Content.First(c => c.MainPage);
            
            Title = Content.Title;

            var contents = context.Content.ToList();
            Menu = new Menu();
            foreach (var content in contents)
            {
                Menu.Add(new MenuItem
                {
                    ContentId = content.Id,
                    ContentName = content.Name,
                    Current = content.Name == Content.Name,
                    Selected = false,
                    SortOrder = content.SortOrder,
                    Title = content.Title
                });
            }




            if (Content.Name == "gallery")
            {
                IQueryable<Product> products = context.Product;
                TotalProductsCount = products.Count();
                products = ApplyOrdering(products, "asc");
                products = ApplyPaging(products, page);
                Products = products.ToList();

            }

            SeoDescription = Content.SeoDescription;
            SeoKeywords = Content.SeoKeywords;
            IsHomePage = Content.MainPage;
        }
Example #15
0
 public ActionResult Edit(int id)
 {
     using (var context = new SiteContainer())
     {
         var product = context.Product.First(p => p.Id == id);
        
         return View(product);
     }
 }
Example #16
0
 public ActionResult Edit(int id, FormCollection collection)
 {
     using (var context = new SiteContainer())
     {
         var product = context.Product.First(p => p.Id == id);
         TryUpdateModel(product, new[] { "SortOrder" });
         product.Description = HttpUtility.HtmlDecode(collection["Description"]);
         context.SaveChanges();
         return RedirectToAction("Index", "Home", new { area = "", id = "gallery" });
     }
 }
Example #17
0
 public ActionResult Delete(int id)
 {
     using (var context = new SiteContainer())
     {
         var product = context.Product.First(p => p.Id == id);
         ImageHelper.DeleteImage(product.ImageSource);
         ImageHelper.DeleteImage(product.PreviewImageSource);
         context.DeleteObject(product);
         context.SaveChanges();
         return RedirectToAction("Index", "Home", new { area = "", id = "gallery" });
     }
 }