public async Task <IActionResult> Create(Partner partner) { if (partner.PhotoFile != null) { try { FileManager fileManager = new FileManager(_webHost); partner.Photo = fileManager.Upload(partner.PhotoFile); } catch (Exception e) { ModelState.AddModelError("Photo", e.Message); throw; } } if (ModelState.IsValid) { _context.Add(partner); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(partner)); }
public async Task <IActionResult> Create(Car car) { if (ModelState.IsValid) { if (car.PhotoFile != null && car.DetailPhotoFile != null && car.CartPhotoFile != null) { try { FileManager manager = new FileManager(_webHostEnvironment); car.Photo = manager.Upload(car.PhotoFile); car.CartPhoto = manager.Upload(car.CartPhotoFile); car.DetailPhoto = manager.Upload(car.DetailPhotoFile); } catch (Exception e) { ModelState.AddModelError("PhotoUplaod", e.Message); throw; } } _context.Add(car); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CarModelId"] = new SelectList(_context.CarModels, "Id", "Name", car.CarModelId); return(View(car)); }
public async Task <IActionResult> Create([Bind("Id,Name")] BlogCategory blogCategory) { if (ModelState.IsValid) { _context.Add(blogCategory); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(blogCategory)); }
public async Task <IActionResult> Create([Bind("Id,Title,Text")] OurVision ourVision) { if (ModelState.IsValid) { _context.Add(ourVision); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(ourVision)); }
public async Task <IActionResult> Create([Bind("Id,Icon,Name")] CarType carType) { if (ModelState.IsValid) { _context.Add(carType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(carType)); }
public async Task <IActionResult> Create([Bind("Id,Photo,Name,Position,FacebookLink,TwitterLink,InstagramLink,LinkedInLink")] Team team) { if (ModelState.IsValid) { _context.Add(team); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(team)); }
public async Task <IActionResult> Create([Bind("Id,Icon,Title,Text")] WhatWeOffer whatWeOffer) { if (ModelState.IsValid) { _context.Add(whatWeOffer); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(whatWeOffer)); }
public async Task <IActionResult> Create([Bind("Id,Question,Answer")] Faq faq) { if (ModelState.IsValid) { _context.Add(faq); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(faq)); }
public async Task <IActionResult> Create([Bind("Id,Name,Status")] Coupon coupon) { if (ModelState.IsValid) { _context.Add(coupon); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(coupon)); }
public async Task <IActionResult> Create([Bind("Id,FacebookLink,TwitterLink,InstagramLink,GoogleLink,LinkedInLink,Phone,SupPhone,Email,SaleEmail,MainAdress,Adress,Logo,FooterLogo,FooterText,Payment")] Setting setting) { if (ModelState.IsValid) { _context.Add(setting); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(setting)); }
public async Task <IActionResult> Create([Bind("Id,Text,Name,Position,Company,Photo")] Testimonial testimonial) { if (ModelState.IsValid) { _context.Add(testimonial); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(testimonial)); }
public async Task <IActionResult> Create([Bind("Id,Photo,Title,Text")] SliderItem sliderItem) { if (ModelState.IsValid) { _context.Add(sliderItem); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(sliderItem)); }
public async Task <IActionResult> Create([Bind("Id,Name,CarBrandId")] CarModel carModel) { if (ModelState.IsValid) { _context.Add(carModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CarBrandId"] = new SelectList(_context.CarBrands, "Id", "Name", carModel.CarBrandId); return(View(carModel)); }
public async Task <IActionResult> Create([Bind("Id,Name,Price,OrderItemId")] CarExtraService carExtraService) { if (ModelState.IsValid) { _context.Add(carExtraService); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["OrderItemId"] = new SelectList(_context.OrderItems, "Id", "Id", carExtraService.OrderItemId); return(View(carExtraService)); }
public async Task <IActionResult> Create([Bind("Id,Name,BlogId")] Tag tag) { if (ModelState.IsValid) { _context.Add(tag); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["BlogId"] = new SelectList(_context.Blogs, "Id", "InfoText", tag.BlogId); return(View(tag)); }
public async Task <IActionResult> Create([Bind("Id,GalleryId,Photo,PhotoSm,PhotoSmFile,PhotoFile")] GalleryItem galleryItem) { if (galleryItem.PhotoFile != null) { try { FileManager fileManager = new FileManager(_webHostEnvironment); galleryItem.Photo = fileManager.Upload(galleryItem.PhotoFile); galleryItem.PhotoSm = fileManager.Upload(galleryItem.PhotoSmFile); } catch (Exception e) { ModelState.AddModelError("PhotoFile", e.Message); } } if (ModelState.IsValid) { _context.Add(galleryItem); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(galleryItem)); }