public async Task <IActionResult> Event(Message mes) { if (ModelState.IsValid) { await _toursDbContext.AddAsync(mes); await _toursDbContext.SaveChangesAsync(); } else { return(RedirectToAction("Error")); } return(Json(new { Result = "Success", Message = "Send Successfully" })); }
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)); }
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("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,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)); }
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)); }
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 async Task <IActionResult> Create([Bind("Id,TourImage,TourIcon,TourName,TourTitle,TourTime,TourAction,ServiceId,Duration,TourId")] Incoming incoming, IFormFile TourImage) { //CustomDateTimeFile customDateTimeFile = new CustomDateTimeFile(); //string fileName = customDateTimeFile.GetFileName(TourImage.FileName); if (ModelState.IsValid) { //incoming.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(incoming); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ServiceId"] = new SelectList(_context.Services, "Id", "Id", incoming.ServiceId); ViewData["TourId"] = new SelectList(_context.Tours, "Id", "ImagePath", incoming.TourId); return(View(incoming)); }
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)); }
public async Task <IActionResult> Naftalan(PersonalInformation bron) { List <ValidationResult> lists = new List <ValidationResult>(); ValidationContext contet = new ValidationContext(bron); Validator.TryValidateObject(bron, contet, lists, true); var d = lists; if (ModelState.IsValid) { await _toursDbContext.AddAsync(bron); await _toursDbContext.SaveChangesAsync(); } else { return(RedirectToAction("Error")); } return(Json(new { Result = "Success", Message = "Send Successfully" })); }