예제 #1
0
 public IActionResult UploadAsset(AssetUploadViewModel ass)
 {
     ViewBag.ass          = ass;
     ViewData["filename"] = ass.assetFile.FileName;
     ViewData["filesize"] = ass.assetFile.Length;
     return(View());
 }
예제 #2
0
        public IActionResult UploadAssetAction(AssetUploadViewModel fileInfo)
        {
            if (fileInfo.Equals(null))
            {
                return(RedirectToAction("Index", "Home"));
            }
            string unFileName   = null;
            string uploadFolder = Path.Combine(hostingEnvironment.WebRootPath, "UserData", "assetFiles");

            unFileName = "GB_" + Guid.NewGuid().ToString() + "_" + fileInfo.assetFile.FileName;
            string filePath = Path.Combine(uploadFolder, unFileName);
            //fileInfo.assetFile.CopyTo(new FileStream(filePath, FileMode.Create));

            AssetModel dbAsset = new AssetModel {
                title       = fileInfo.title,
                description = fileInfo.description,
                price       = fileInfo.priceTag,
                down_count  = 0,
                rating      = 0,
                user        = JsonConvert.DeserializeObject <UserModel>(HttpContext.Session.GetString("User")).id,
                filePath    = filePath,
            };

            dal.assets.Add(dbAsset);
            dal.SaveChanges();

            IFormFile file = fileInfo.assetFile;

            return(Content(fileInfo.priceTag.ToString()));
        }
예제 #3
0
 public IActionResult UploadAction(AssetUploadViewModel formAsset)
 {
     return(View());
 }