Example #1
0
        public ActionResult Edit(int id, string Title, string Description, int?CatalogID, string Name, string Phone, string Address, string Price, SupplyDemand SupplyDemand, int Top)
        {
            var information = DB.Informations.Find(id);

            information.Title        = Title;
            information.Description  = Description;
            information.CatalogID    = CatalogID;
            information.Name         = Name;
            information.Phone        = Phone;
            information.Top          = Top;
            information.Address      = Address;
            information.SupplyDemand = SupplyDemand;
            information.Price        = Price;

            var Video = Request.Files["Video"];

            if (Video != null && Video.ContentLength > 0)
            {
                var fname = Guid.NewGuid().ToString().Replace("-", "") + ((string.IsNullOrEmpty(Path.GetExtension(Video.FileName)) && Video.ContentType.IndexOf("image") < 0) ? ".3gp" : Path.GetExtension(Video.FileName));
                if (Path.GetExtension(Video.FileName) == ".3gp")
                {
                    var destname = Guid.NewGuid().ToString().Replace("-", "") + ".mp4";
                    Video.SaveAs(Server.MapPath("~/Files/Video/" + fname));
                    Helpers.Video.ChangeFilePhy(Server.MapPath("~/Files/Video/" + fname), Server.MapPath("~/Files/Video/" + destname), "480", "320");
                    information.VideoURL = destname;
                }
                else
                {
                    Video.SaveAs(Server.MapPath("~/Files/Video/" + fname));
                    information.VideoURL = fname;
                }
            }

            DB.SaveChanges();
            return(RedirectToAction("Success", "Shared"));
        }
Example #2
0
        public ActionResult Create(string Title, string Description, int?CatalogID, string Name, string Phone, string Address, string Price, SupplyDemand SupplyDemand)
        {
            var Information = new Information
            {
                Title        = Title,
                Description  = Description,
                Name         = Name,
                Phone        = Phone,
                Address      = Address,
                CatalogID    = CatalogID,
                UserID       = CurrentUser.ID,
                Time         = DateTime.Now,
                SupplyDemand = SupplyDemand,
                Type         = InformationType.本地通信息,
                Verify       = true,
                Price        = Price
            };

            var Video = Request.Files["Video"];

            if (Video != null)
            {
                var fname = Guid.NewGuid().ToString().Replace("-", "") + ((string.IsNullOrEmpty(Path.GetExtension(Video.FileName)) && Video.ContentType.IndexOf("image") < 0) ? ".3gp" : Path.GetExtension(Video.FileName));
                if (Path.GetExtension(Video.FileName) == ".3gp")
                {
                    var destname = Guid.NewGuid().ToString().Replace("-", "") + ".mp4";
                    Video.SaveAs(Server.MapPath("~/Files/Video/" + fname));
                    Helpers.Video.ChangeFilePhy(Server.MapPath("~/Files/Video/" + fname), Server.MapPath("~/Files/Video/" + destname), "480", "320");
                    Information.VideoURL = destname;
                }
                else
                {
                    Video.SaveAs(Server.MapPath("~/Files/Video/" + fname));
                    Information.VideoURL = fname;
                }
            }

            DB.Informations.Add(Information);
            DB.SaveChanges();
            return(RedirectToAction("Success", "Shared"));
        }