Beispiel #1
0
        public IActionResult DeleteConfirmed(int id)
        {   /*Delete code from parent table */
            var c1 = (from a in _context.Allvideo where a.VideoId == id select a);

            _context.RemoveRange(c1);
            _context.SaveChanges();


            /*Delete code from chilled table */
            var c = _context.Videonews.Find(id);

            _context.Videonews.Remove(c);
            _context.SaveChanges();
            return(RedirectToAction(nameof(Index)));
        }
Beispiel #2
0
        public ActionResult CaptionImage(IFormFile file, int id)
        {
            try
            {
                if (file == null || file.Length == 0)
                {
                    return(Content("File not selceted"));
                }
                if (file.Length > 0)
                {
                    var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "featuresNews/" + file.FileName);

                    using (var stream = new FileStream(path, FileMode.Create))
                    {
                        file.CopyTo(stream);
                    }
                    Newsinfo st = (from s in _context.Newsinfo where s.Newsserial == id select s).First();
                    st.CaptionPicture = file.FileName;
                    _context.SaveChanges();
                }
                ViewBag.Message = "File Uploaded Successfully!" + ":" + id;
                return(RedirectToAction("Index"));
            }
            catch (Exception)
            {
                ViewBag.Message = "File upload failes!";
                return(View());
            }
        }
Beispiel #3
0
        public ActionResult UploadFile(IFormFile file, int id)
        {
            try
            {
                if (file == null || file.Length == 0)
                {
                    return(Content("file not selected"));
                }
                if (file.Length > 0)
                {
                    var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "Ads/" + file.FileName);

                    using (var stream = new FileStream(path, FileMode.Create))
                    {
                        file.CopyTo(stream);
                    }
                    AdsDetails st = (from s in _context.AdsDetails where s.Id == id select s).First();
                    st.Picture = file.FileName;
                    _context.SaveChanges();
                }
                ViewBag.Message = "File Uploaded Successfully!!" + ":" + id;
                return(RedirectToAction("Index"));
            }
            catch
            {
                ViewBag.Message = "File upload failed!!";
                return(View());
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            var c1 = (from a in _context.Allvideo where a.VideoId == id select a);

            // c1=_context.Allvideo.Find(m=>m.)
            _context.RemoveRange(c1);
            _context.SaveChanges();

            var c = _context.Videonews.Find(id);

            _context.Videonews.Remove(c);
            _context.SaveChanges();

            //var videonews = _context.Videonews.Find(id);
            //_context.Videonews.Remove(videonews);
            //_context.SaveChangesAsync();
            return(RedirectToAction(nameof(Index)));
        }