public async Task <ActionResult <KategoriAddDTO> > CreateCategory(KategoriAddDTO category) { var categoryEntity = _mapper.Map <Category>(category); categoryEntity = await _categoryRepository.InsertCategory(categoryEntity); var categoryForReturn = _mapper.Map <KategoriAddDTO>(categoryEntity); return(CreatedAtRoute("GetCategory", new { categoryId = categoryForReturn.Id }, categoryForReturn)); }
public async Task <IActionResult> KategoriEkle(KategoriAddDTO model, IFormFile Logo) { if (ModelState.IsValid) { var kategori = mapper.Map <Kategori>(model); if (Logo != null) { var uzanti = Path.GetExtension(Logo.FileName); var resimAd = Guid.NewGuid() + uzanti; string path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/logo/" + resimAd); using var stream = new FileStream(path, FileMode.Create); await Logo.CopyToAsync(stream); kategori.Logo = resimAd; } await kategoriService.Add(kategori); return(RedirectToAction("Index")); } return(View(model)); }