public async Task <int> CreateOrUpdate(CategoryDto input)
        {
            if (input.Id > 0)
            {
                // update
                var updateData = await _categoryRepos.GetAsync(input.Id);

                input.MapTo(updateData);

                await _categoryRepos.UpdateAsync(updateData);

                return(1);
            }
            else
            {
                var insertData = input.MapTo <Category>();
                int id         = await _categoryRepos.InsertAndGetIdAsync(insertData);

                return(id);
            }
        }
Exemple #2
0
 public async Task UpsertCategory(CategoryDto input)
 {
     try
     {
         var obj = input.MapTo <Category>();
         if (input.Id == 0)
         {
             obj.IsDeleted    = false;
             obj.CreatedBy    = AbpSession.UserId;
             obj.DateCreated  = DateTime.Now;
             obj.DateModified = null;
         }
         else
         {
             obj.ModifiedBy   = AbpSession.UserId;
             obj.DateModified = DateTime.Now;
         }
         await _categoryRepository.InsertOrUpdateAsync(obj);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #3
0
 public static Category ToEntity(this CategoryDto categoryDto)
 {
     return(categoryDto.MapTo <CategoryDto, Category>());
 }
Exemple #4
0
 public CategoryViewModel(CategoryDto output)
 {
     output.MapTo(this);
 }
Exemple #5
0
 public static Category ToEntity(this CategoryDto model, Category destination)
 {
     return(model.MapTo(destination));
 }
Exemple #6
0
 public static Category ToEntity(this CategoryDto model)
 {
     return(model.MapTo <CategoryDto, Category>());
 }
Exemple #7
0
 public CategoryDto Update(CategoryDto dto)
 {
     return(_categoryDomainService.Update(dto.MapTo <Category>()).MapTo <CategoryDto>());
 }
Exemple #8
0
 public async Task CreateOrUpdateCategoryAsync(CategoryDto input)
 {
     await _categoryManager.CreateOrUpdateCategoryAsync(input.MapTo <Category>());
 }