Exemple #1
0
        public ActionResult Create(FormCollection form, HttpPostedFileBase uploadFile)
        {
            try
            {
                using (var context = new ShopContainer())
                {

                    var brand = new Brand
                                    {
                                        Name = form["Name"], 
                                        Title = form["Title"],
                                        Description = form["Description"], 
                                        SeoDescription = form["SeoDescription"], 
                                        SeoKeywords = form["SeoKeywords"]
                                    };
                    if (uploadFile != null)
                    {
                        string fileName = IOHelper.GetUniqueFileName("~/Content/Images", uploadFile.FileName);
                        string filePath = Server.MapPath("~/Content/Images");
                        filePath = Path.Combine(filePath, fileName);
                        uploadFile.SaveAs(filePath);
                        brand.Logo = fileName;
                    }
                    context.AddToBrand(brand);
                    context.SaveChanges();
                    return RedirectToAction("Index");
                }
            }
            catch
            {
                return View();
            }
        }
Exemple #2
0
 /// <summary>
 /// Create a new Brand object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="title">Initial value of the Title property.</param>
 public static Brand CreateBrand(global::System.Int32 id, global::System.String name, global::System.String title)
 {
     Brand brand = new Brand();
     brand.Id = id;
     brand.Name = name;
     brand.Title = title;
     return brand;
 }
Exemple #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Brand EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToBrand(Brand brand)
 {
     base.AddObject("Brand", brand);
 }