Esempio n. 1
0
        public async Task <IActionResult> Create([Bind("Id,ImagePath,ImageText,Title,SubTitle,Duration,Code,Price,AboutTourText,AboutTourNumber,TourImage,TourName,TourInformation,TourVideo,TourCheckIn,TourText,TourTime,TourAdditional,TourSecondAdditional,Number,SecondNumber,Email,SiteAddress,Address,EventId")] BakuJara bakuJara, IFormFile ImagePath)
        {
            CustomDateTimeFile customDateTimeFile = new CustomDateTimeFile();
            string             fileName           = customDateTimeFile.GetFileName(ImagePath.FileName);

            if (ModelState.IsValid)
            {
                bakuJara.ImagePath = fileName;
                if (_IsAcceptedFormat(ImagePath.ContentType))
                {
                    string path = Path.Combine(hostingEnvironment.WebRootPath, "images", fileName);
                    byte[] data = new byte[ImagePath.Length];

                    using (FileStream fileStream = new FileStream(path, FileMode.Create))
                    {
                        await ImagePath.CopyToAsync(fileStream);
                    }
                }
                await _context.AddAsync(bakuJara);

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EventId"] = new SelectList(_context.Events, "Id", "Id", bakuJara.EventId);
            return(View(bakuJara));
        }
        public IActionResult Jara()
        {
            ViewBag.Setting = _toursDbContext.Settings.First();
            BakuJara model = _toursDbContext.BakuJaras.FirstOrDefault();

            return(View(model));
        }
Esempio n. 3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,ImagePath,ImageText,Title,SubTitle,Duration,Code,Price,AboutTourText,AboutTourNumber,TourImage,TourName,TourInformation,TourVideo,TourCheckIn,TourText,TourTime,TourAdditional,TourSecondAdditional,Number,SecondNumber,Email,SiteAddress,Address,EventId")] BakuJara bakuJara)
        {
            if (id != bakuJara.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(bakuJara);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BakuJaraExists(bakuJara.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EventId"] = new SelectList(_context.Events, "Id", "Id", bakuJara.EventId);
            return(View(bakuJara));
        }