public async Task <CategoryDTO> RegisterCategoryAsync(CategoryDTO categoryDTO) { var category = categoryDTO.ToEntity <Eduction.Core.Domains.Category>(); await _categoryRepository.InsertAsync(category); categoryDTO.ID = category.ID; return(categoryDTO); }
public static Category CreateCategory(this IGenericRepository <Category> cat, CategoryDTO categoryDto) { Category catObj = new Category(); categoryDto.ToEntity(catObj); cat.Add(catObj); return(catObj); }
public void Add(CategoryDTO category) { try { LoggerInstance.Log("Adding news"); ValidateCategory(category); DatabaseInstance.Save(category.ToEntity <CategoryNPocoEntity>(EntityManager)); } catch (Exception ex) { LoggerInstance.Log(ex); throw ex; } }
public void Update(CategoryDTO dto) { try { LoggerInstance.Log("Updating category"); ValidateCategory(dto); DatabaseInstance.Update(dto.ToEntity <ICategoryEntity>(EntityManager)); } catch (Exception ex) { LoggerInstance.Log(ex); throw ex; } }
public async Task <IHttpActionResult> Update([FromBody] CategoryDTO CategoryDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var entity = await CategoryService.FindOneAsync(CategoryDto.Id); entity = CategoryDto.ToEntity(entity); entity.LastUserId = User.Identity.GetUserId(); entity.LastTime = DateTime.Now; await CategoryService.UpdateAsync(entity); return(Ok(entity.ToModel())); }