예제 #1
0
        public ActionResult CreateStall(string Name, string Description, HttpPostedFileBase ImageData)
        {
            if (!IsAuthorized())
            {
                return(View("Error"));
            }
            Stall obj = new Stall();

            obj.Fields.Name        = Name;
            obj.Fields.Description = Description;
            obj.Fields.UserID      = UserID;
            var type = ImageData.ContentType;

            obj.Fields.ContentType = type;
            MemoryStream target = new MemoryStream();

            ImageData.InputStream.CopyTo(target);
            obj.Fields.Logo = target.ToArray();

            if (obj.Fields.Logo.Length > 1000000 || (type != "image/x-png" && type != "image/gif" && type != "image/jpeg"))
            {
                return(RedirectToAction("CreateStall"));
            }
            obj.Save();
            return(RedirectToAction("Index"));
        }
예제 #2
0
        public ActionResult CreateStall(string Name, string Description, HttpPostedFileBase Logo)
        {
            Stall obj = new Stall();

            obj.Fields.Name        = Name;
            obj.Fields.Description = Description;
            obj.Fields.UserID      = UserID;
            //using (var binaryReader = new BinaryReader(Logo.InputStream))
            //	obj.Fields.Logo = binaryReader.ReadBytes(Logo.ContentLength);
            obj.Save();
            return(RedirectToAction("Index"));
        }