コード例 #1
0
        public async Task <ActionResult> Edit(int Id, String Tittle, String Description, String Category, String createdBy, String Date, HttpPostedFileBase uploadFile)
        {
            FileData fileData = await db.FileDatas.FindAsync(Id);

            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.PdfUrl          = "http://mobileappsports.azurewebsites.net/Content/files/" + fileName;
                    db.Entry(fileData).State = EntityState.Modified;
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Index"));
                }
                catch {
                }
            }
            return(View(fileData));
        }
コード例 #2
0
        public async Task <ActionResult> Edit(int id, String UrlToImage, HttpPostedFileBase uploadFile, String Categoty, String Title, String Description)
        {
            Images images = await db.Images.FindAsync(id);

            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.Categoty        = Categoty;
                images.Title           = Title;
                images.Visibility      = "show";
                images.Description     = Description;
                db.Entry(images).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(images));
        }
コード例 #3
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,UrlToVideo,Category,Title,Description")] Videos videos)
        {
            if (ModelState.IsValid)
            {
                db.Entry(videos).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(videos));
        }
コード例 #4
0
        public async Task <ActionResult> Edit(int id, String Author, String title, String Description, String PublishedAt, String Url, String UrlToImage, String Category, HttpPostedFileBase uploadFile)
        {
            NewsData newsData = await db.NewsDatas.FindAsync(id);

            if (ModelState.IsValid)
            {
                if (UrlToImage != "")
                {
                    newsData.UrlToImage = UrlToImage;
                }

                else
                {
                    try

                    {
                        var fileName = Path.GetFileName(uploadFile.FileName);
                        var path     = Path.Combine(Server.MapPath("~/Content/files"), fileName);
                        uploadFile.SaveAs(path);
                        newsData.UrlToImage = "http://mobileappsports.azurewebsites.net/Content/files/" + fileName;
                    }
                    catch { }
                }
                newsData.Author      = Author;
                newsData.title       = title;
                newsData.Description = Description;
                newsData.PublishedAt = PublishedAt;
                newsData.Url         = Url;
                newsData.Category    = Category;

                db.Entry(newsData).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(newsData));
        }