public async Task <UnitDto> CreateUnitAsync(CreateUnitInput input) { var entity = ObjectMapper.Map <Unit>(input); entity = await _menuRepository.InsertAsync(entity); return(ObjectMapper.Map <UnitDto>(entity)); }
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)); }
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 }); }
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);