예제 #1
0
        public async Task <UnitDto> CreateUnitAsync(CreateUnitInput input)
        {
            var entity = ObjectMapper.Map <Unit>(input);

            entity = await _menuRepository.InsertAsync(entity);

            return(ObjectMapper.Map <UnitDto>(entity));
        }
예제 #2
0
        public async Task <IServiceResult <int> > Create(CreateUnitInput input)
        {
            var unit = new Unit(input.Name);
            await _databaseContext.Units.AddAsync(unit);

            await _databaseContext.SaveChangesAsync();

            return(ServiceResult <int> .Ok(unit.Id));
        }
예제 #3
0
 public OutputBase CreateUnit(CreateUnitInput input)
 {
     if (_unitRepository.Query(q => q.Any(u => u.Name == input.Name)))
     {
         return(new OutputBase {
             Message = "A unit with the same name already exist", Success = false
         });
     }
     _unitRepository.Insert(Mapper.Map <Unit>(input));
     return(new OutputBase {
         Message = "Unit added", Success = true
     });
 }
예제 #4
0
 public async Task <UnitDto> CreateUnit([FromBody] CreateUnitInput input)
 {
     return(await _UnitAppService.CreateUnitAsync(input));
 }
 public async Task <IServiceResult <int> > Post(CreateUnitInput input) => await _createUnitService.Create(input);