public async Task <IActionResult> ArticleCategoryCreateAdmin(CategoryModel model, IFormFile file) { var entity = new Category() { Tittle = model.Tittle, Url = model.Url, }; if (file != null) { var extention = Path.GetExtension(file.FileName); var randomName = string.Format($"{Guid.NewGuid()}{extention}"); entity.Image = randomName; var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\img", randomName); using (var stream = new FileStream(path, FileMode.Create)) { await file.CopyToAsync(stream); } } _categoryServices.Create(entity); TempData.Put("message", new AlertMessage() { Title = "Yeni Kategori", Message = $"{entity.Tittle} Kategorisi Başarıyla Eklendi", AlertType = "success" }); return(RedirectToAction("ArticleCategoryListAdmin")); }
public async Task <IActionResult> Create([Bind("ID,Name,Code,IdCategoryType")] VMCreateCategory vmCreateCategory) { if (!ModelState.IsValid) { return(JSErrorModelState()); } var now = DateTime.Now; var user = new Category { Name = vmCreateCategory.Name, Code = vmCreateCategory.Code, IdCategoryType = vmCreateCategory.IdCategoryType, CreateDate = now, CreatedBy = GetCurrUser(), UpdatedBy = null, UpdatedDate = null }; //var user = _mapper.Map<User>(vmUser); //user.CreateDate = now; //user.CreatedBy = GetCurrUser(); var rs = await _categoryServices.Create(user); return(CustJSonResult(rs)); }
public IActionResult CategoryCreate(CategoryModel model) { var entity = new Category() { Title = model.Title }; _categoryServices.Create(entity); return(RedirectToAction("CategoryList")); }
public IActionResult CategoryCreate(CategoryModel model) { var entity = new Category() { Name = model.Name, Url = model.Url, }; _categoryServices.Create(entity); var msg = new AlertMessage() { Message = $"{entity.Name} isimli kategori eklendi", AlertType = "success" }; TempData["message"] = JsonConvert.SerializeObject(msg); return(RedirectToAction("CategoryList")); }
public ActionResult Post([FromBody] Category Category) { var createdCategory = _Categories.Create(Category); return(Ok(createdCategory)); }
public async Task CreateCategoryAsync(CategoryDto category) { CheckIfCategoryNameIsNull(category); await _categoryServices.Create(category); }