public async Task <IActionResult> PutNewsinfo([FromRoute] int id, [FromBody] Newsinfo newsinfo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != newsinfo.Newsserial)
            {
                return(BadRequest());
            }

            _context.Entry(newsinfo).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!NewsinfoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        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 #3
0
        public async Task <IActionResult> PutAdsDetails([FromRoute] int id, [FromBody] AdsDetails adsDetails)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != adsDetails.Id)
            {
                return(BadRequest());
            }

            _context.Entry(adsDetails).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AdsDetailsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #4
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 #5
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));
        }