public async Task <IActionResult> Update(ArticleCategoryModel model) { if (model.Id <= 0) { return(RedirectToErrorPage()); } var exist = await _articleCategoryService.FindAsync(new IdRequestFilter <int> { CanGetInactived = true, Id = model.Id }); if (exist == null) { return(RedirectToErrorPage()); } var category = new ArticleCategoryModifyRequest { Description = model.Description, ParentId = model.ParentId, Name = model.Name, UpdatedById = LoggedUserId, Id = model.Id }; await _articleCategoryService.UpdateAsync(category); return(RedirectToAction(nameof(Detail), new { id = category.Id })); }
public async Task <bool> ActiveAsync(ArticleCategoryModifyRequest request) { await _articleCategoryRepository.Get(x => x.Id == request.Id) .Set(x => x.StatusId, (int)ArticleCategoryStatus.Actived) .Set(x => x.UpdatedById, request.UpdatedById) .Set(x => x.UpdatedDate, DateTimeOffset.UtcNow) .UpdateAsync(); return(true); }
public async Task <bool> UpdateAsync(ArticleCategoryModifyRequest category) { var exist = await _articleCategoryRepository.Get(x => x.Id == category.Id) .Set(x => x.Description, category.Description) .Set(x => x.Name, category.Name) .Set(x => x.ParentId, category.ParentId) .Set(x => x.UpdatedById, category.UpdatedById) .Set(x => x.UpdatedDate, DateTime.UtcNow) .UpdateAsync(); return(true); }
public async Task <int> CreateAsync(ArticleCategoryModifyRequest category) { var newCategory = new ArticleCategory() { Description = category.Description, Name = category.Name, ParentId = category.ParentId, CreatedById = category.CreatedById, UpdatedById = category.UpdatedById, UpdatedDate = DateTime.UtcNow, CreatedDate = DateTime.UtcNow, StatusId = ArticleCategoryStatus.Actived.GetCode() }; var id = await _articleCategoryRepository.AddWithInt32EntityAsync(newCategory); return(id); }
public async Task <IActionResult> Create(ArticleCategoryModel model) { var category = new ArticleCategoryModifyRequest { Description = model.Description, ParentId = model.ParentId, Name = model.Name, UpdatedById = LoggedUserId, CreatedById = LoggedUserId }; var exist = await _articleCategoryService.FindByNameAsync(model.Name); if (exist != null) { return(RedirectToErrorPage()); } category.UpdatedById = LoggedUserId; category.CreatedById = LoggedUserId; var id = await _articleCategoryService.CreateAsync(category); return(RedirectToAction(nameof(Detail), new { id })); }
public async Task <bool> UpdateAsync(ArticleCategoryModifyRequest category) { return(await _articleCategoryRepository.UpdateAsync(category)); }
public async Task <int> CreateAsync(ArticleCategoryModifyRequest category) { return(await _articleCategoryRepository.CreateAsync(category)); }
public async Task <bool> DeactivateAsync(ArticleCategoryModifyRequest request) { return(await _articleCategoryRepository.DeactivateAsync(request)); }