public async Task <ActionResult> Create(String Tittle, String Description, String Category, String createdBy, String Date, HttpPostedFileBase uploadFile) { FileData fileData = new FileData(); if (ModelState.IsValid) { try { var fileName = Path.GetFileName(uploadFile.FileName); var path = Path.Combine(Server.MapPath("~/Content/files"), fileName); uploadFile.SaveAs(path); fileData.Tittle = Tittle; fileData.Description = Description; fileData.Category = Category; fileData.Date = Date; fileData.createdBy = createdBy; fileData.Visibility = "show"; fileData.PdfUrl = "http://mobileappsports.azurewebsites.net/Content/files/" + fileName; db.FileDatas.Add(fileData); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } catch { } } return(View(fileData)); }
public async Task <ActionResult> Create(String UrlToImage, HttpPostedFileBase uploadFile, String Categoty, String Title, String Description) { Images images = new Images(); if (ModelState.IsValid) { if (UrlToImage != "") { images.UrlToImage = UrlToImage; } else { try { var fileName = Path.GetFileName(uploadFile.FileName); var path = Path.Combine(Server.MapPath("~/Content/files"), fileName); uploadFile.SaveAs(path); images.UrlToImage = "http://mobileappsports.azurewebsites.net/Content/files/" + fileName; } catch { } } images.Visibility = "show"; images.Categoty = Categoty; images.Title = Title; images.Description = Description; db.Images.Add(images); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(images)); }
public async Task <ActionResult> Create(String UrlToVideo, String Category, String Title, String Description) { Videos videos = new Videos(); if (ModelState.IsValid) { videos.UrlToVideo = UrlToVideo; videos.Category = Category; videos.Title = Title; videos.Description = Description; videos.Visibility = "show"; db.Videos.Add(videos); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(videos)); }
public async Task <ActionResult> Create(String Author, String title, String Description, String PublishedAt, String Url, String UrlToImage, String Category, HttpPostedFileBase uploadFile) { NewsData data = new NewsData(); if (ModelState.IsValid) { if (UrlToImage != "") { data.UrlToImage = UrlToImage; } else { try { var fileName = Path.GetFileName(uploadFile.FileName); var path = Path.Combine(Server.MapPath("~/Content/files"), fileName); uploadFile.SaveAs(path); data.UrlToImage = "http://mobileappsports.azurewebsites.net/Content/files/" + fileName; } catch { } } data.Author = Author; data.title = title; data.Description = Description; data.PublishedAt = PublishedAt; data.Url = Url; data.Category = Category; db.NewsDatas.Add(data); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(data)); }