public async Task <IActionResult> Create([Bind("VideoNewsId,Title,Category,Keyword,Datetime,Path")] Videonews videonews)
        {
            //if (ModelState.IsValid)
            //{
            //    _context.Add(videonews);
            //    await _context.SaveChangesAsync();
            //    return RedirectToAction(nameof(Index));
            //}
            //return View(videonews);



            if (ModelState.IsValid)
            {
                var ckcategory = _context.Videonews.Where(c => c.VideoNewsId == videonews.VideoNewsId).Count();
                if (ckcategory > 0)
                {
                    ModelState.AddModelError("", "This Video News ID " + videonews.VideoNewsId + " is alredy exists!");
                }

                else
                {
                    _context.Add(videonews);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            }
            return(View(videonews));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("Newsserial,Title,Category,Description,Author,Datetime,Keyword,CaptionPicture,Editor,FeatureNews")] Newsinfo newsinfo)
        {
            if (ModelState.IsValid)
            {
                _context.Add(newsinfo);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(newsinfo));
        }
Beispiel #3
0
        public async Task <IActionResult> Create([Bind("Id,CompanyName,CompanyAddress,Companyurl,Picture,Title,Description,StartDate,EndDate,DailyRate,TotalPrice")] AdsDetails adsDetails)
        {
            if (ModelState.IsValid)
            {
                _context.Add(adsDetails);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(adsDetails));
        }
        public async Task <IActionResult> Create([Bind("Username,Password,Email,Role")] UserDetails userDetails)
        {
            if (ModelState.IsValid)
            {
                userDetails.Password = CalculateSha1(userDetails.Password);
                _context.Add(userDetails);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(userDetails));
        }