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);
        }
Exemplo n.º 2
0
        public static Category CreateCategory(this IGenericRepository <Category> cat, CategoryDTO categoryDto)
        {
            Category catObj = new Category();

            categoryDto.ToEntity(catObj);
            cat.Add(catObj);
            return(catObj);
        }
Exemplo n.º 3
0
 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;
     }
 }
Exemplo n.º 4
0
 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;
     }
 }
Exemplo n.º 5
0
        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()));
        }