Ejemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("Id,TourImage,TourName,TourPrice,TourTime,TourAction,TourDuration")] MainPage mainPage, IFormFile TourImage)
        {
            CustomDateTimeFile customDateTimeFile = new CustomDateTimeFile();
            string             fileName           = customDateTimeFile.GetFileName(TourImage.FileName);

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

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

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(mainPage));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("ImageTitle,Text,SubText,Id,ImagePath,Title,SubTitle")] About about, IFormFile ImagePath)
        {
            CustomDateTimeFile customDateTimeFile = new CustomDateTimeFile();
            string             fileName           = customDateTimeFile.GetFileName(ImagePath.FileName);

            if (ModelState.IsValid)
            {
                about.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(about);

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(about));
        }
        public async Task <IActionResult> Create([Bind("Id,ImagePath,ImageText,Title,SubTitle,Duration,Code,Price,AboutTourText,AboutTourNumber,TourImage,TourName,TourInformation,TourVideo,TourCheckIn,TourText,TourTime,TourAdditional,TourAdditionalSecond,Number,SecondNumber,Email,SiteAddress,Address")] ShakiPage shakiPage, IFormFile TourImage)
        {
            CustomDateTimeFile customDateTimeFile = new CustomDateTimeFile();
            string             fileName           = customDateTimeFile.GetFileName(TourImage.FileName);

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

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

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(shakiPage));
        }
        public async Task <IActionResult> Create([Bind("Id,Price,ImagePath,ImageTitle,Title,SubTitle,Phone,OtherPhone,Email,SiteAddress,Address,ServiceId,TourId")] Transport transport, IFormFile ImagePath)
        {
            CustomDateTimeFile customDateTimeFile = new CustomDateTimeFile();
            string             fileName           = customDateTimeFile.GetFileName(ImagePath.FileName);

            if (ModelState.IsValid)
            {
                transport.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(transport);

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ServiceId"] = new SelectList(_context.Services, "Id", "Id", transport.ServiceId);
            ViewData["TourId"]    = new SelectList(_context.Tours, "Id", "ImagePath", transport.TourId);
            return(View(transport));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("Id,ImagePath,ImageTitle,Title,Subtitle,Text,ServiceId")] Emergency emergency, IFormFile ImagePath)
        {
            CustomDateTimeFile customDateTimeFile = new CustomDateTimeFile();
            string             fileName           = customDateTimeFile.GetFileName(ImagePath.FileName);

            if (ModelState.IsValid)
            {
                emergency.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(emergency);

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ServiceId"] = new SelectList(_context.Services, "Id", "Id", emergency.ServiceId);
            return(View(emergency));
        }
Ejemplo n.º 6
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));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Create([Bind("Id,ImagePath,ImageTitle,Title,SubTitle,EventImage,EventIcon,EventName,EventTitle,EventTime,EventAction,Duration,ServiceId")] Event @event, IFormFile EventImage)
        {
            CustomDateTimeFile customDateTimeFile = new CustomDateTimeFile();
            string             fileName           = customDateTimeFile.GetFileName(EventImage.FileName);

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

                    using (FileStream fileStream = new FileStream(path, FileMode.Create))
                    {
                        await EventImage.CopyToAsync(fileStream);
                    }
                }
                await _context.AddAsync(@event);

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ServiceId"] = new SelectList(_context.Services, "Id", "Id", @event.ServiceId);
            return(View(@event));
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> Create([Bind("Id,TourImage,TourIcon,TourName,TourTitle,TourTime,TourAction,Duration,ServiceId,TourId")] Health health, IFormFile TourImage)
        {
            CustomDateTimeFile customDateTimeFile = new CustomDateTimeFile();
            string             fileName           = customDateTimeFile.GetFileName(TourImage.FileName);

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

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

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ServiceId"] = new SelectList(_context.Services, "Id", "Id", health.ServiceId);
            ViewData["TourId"]    = new SelectList(_context.Tours, "Id", "ImagePath", health.TourId);
            return(View(health));
        }