public async Task <ServiceResponse> Create(ServiceDTO newService) { var service = ServiceMapper.Map(newService); if (service.Name == null) { string errorMessage1 = "Service name not found."; Log.Error(errorMessage1); return(new ServiceResponse(errorMessage1)); } if (service.Description == null) { string errorMessage2 = "Service description not found."; Log.Error(errorMessage2); return(new ServiceResponse(errorMessage2)); } try { await _serviceRepository.Create(service); await _context.SaveChangesAsync(); return(new ServiceResponse(ServiceMapper.Map(service))); } catch (Exception exception) { string errorMessage = $"An error occured when creating the item: {exception.Message}"; return(new ServiceResponse(errorMessage)); } }
/// <summary> /// Load your modules or register your services here! /// </summary> /// <param name="kernel">The kernel.</param> private static void RegisterServices(IKernel kernel) { RepositoryMapper repoMapper = new RepositoryMapper(); ServiceMapper serviceMapper = new ServiceMapper(); repoMapper.Map(kernel); serviceMapper.Map(kernel); }
public GetApartmentModel GetApartmentById(Guid id) { var apartment = Repository.Filter(a => a.Id == id, new [] { "Owner" }).FirstOrDefault(); if (apartment == null) { throw new NotFoundException("Invalid apartment id"); } return(ServiceMapper.Map <GetApartmentModel>(apartment)); }
/// <summary> /// Open account /// </summary> /// <param name="v">name</param> /// <param name="base">type</param> /// <param name="id">id</param> public void OpenAccount(decimal balance, decimal bonus, int id) { Account acc = new Account() { Id = id, Balance = balance, BonusPoints = bonus }; unitOfWork.Accounts.AddAccount(ServiceMapper.Map(acc)); ///to-do }
/// <summary> /// Withdraw money /// </summary> /// <param name="id">Id</param> /// <param name="money">Money</param> public void WithdrawAccount(int id, decimal money) { var account = ServiceMapper.Map(unitOfWork.Accounts.GetAccount(id)); if (money <= 0 || account == null) { throw new ArgumentException(); } account.Balance -= money; account.BonusPoints -= BonusPoints.GetBonusPoints("gold", money); unitOfWork.Accounts.UpdateAccount(ServiceMapper.Map(account)); }
public async Task <ServiceResponse> GetById(int id) { var service = await _serviceRepository.GetById(id); if (service == null) { string errorMessage = "Service not found."; Log.Error(errorMessage); return(new ServiceResponse(errorMessage)); } return(new ServiceResponse(ServiceMapper.Map(service))); }
public async Task <IActionResult> Update([FromBody] ServiceModel data) { var dataUpdate = await _servicesService.Update(ServiceMapper.Map(data)); return(Ok()); }
public List <ApartmentModel> GetAllApartments() { return(ServiceMapper.Map <List <ApartmentModel> >(Repository.GetAll())); }
public List <ApartmentModel> GetApartmentsByBuildingId(Guid buildingId) { var apartments = Repository.Filter(b => b.BuildingId == buildingId); return(ServiceMapper.Map <List <ApartmentModel> >(apartments)); }
public ApartmentModel GetApartmentByOwnerId(Guid ownerId) { var apartment = Repository.Filter(a => a.OwnerId == ownerId).FirstOrDefault(); return(ServiceMapper.Map <ApartmentModel>(apartment)); }
public async Task <IActionResult> AddService([FromBody] ServiceModel service) { var newService = await _servicesService.AddService(ServiceMapper.Map(service)); return(Ok(newService)); }
public async Task <Service> Get(int id) { var data = await _serviceRepository.Get(id); return(ServiceMapper.Map(data)); }
public async Task <Service> UpdateService(Service service) { var updated = await _servicesRepository.Update(ServiceMapper.Map(service)); return(ServiceMapper.Map(updated)); }
public async Task <Service> AddService(Service service) { var addedEntity = await _servicesRepository.Add(ServiceMapper.Map(service)); return(ServiceMapper.Map(addedEntity)); }
public async Task <IActionResult> Add([FromBody] ServiceModel data) { var dataEntity = await _servicesService.Add(ServiceMapper.Map(data)); return(Ok(dataEntity)); }
public Account GetBrand(int id) { return(ServiceMapper.Map(unitOfWork.Accounts.GetAccount(id))); }
public IEnumerable <Account> GetAllAccounts() { return(ServiceMapper.Map(unitOfWork.Accounts.GetAll())); }
public List <BuildingModel> GetBuildingsByOwnerId(Guid ownerId) { var buildings = Repository.Filter(b => b.OwnerId == ownerId); return(ServiceMapper.Map <List <BuildingModel> >(buildings)); }
public async Task <Service> GetService(int id) { var entidad = await _servicesRepository.Get(id); return(ServiceMapper.Map(entidad)); }
public static SeventyPercentClubEntry MapToDomain(this SeventyPercentClubEntryDto dto) => ServiceMapper.Map <SeventyPercentClubEntry>(dto);
public async Task <IActionResult> UpdateAdmin([FromBody] ServiceModel service) { var name = await _servicesService.UpdateService(ServiceMapper.Map(service)); return(Ok(name)); }
public static SeventyPercentClubEntryDto MapToDto(this SeventyPercentClubEntry domain) => ServiceMapper.Map <SeventyPercentClubEntryDto>(domain);
public async Task <Service> Update(Service service) { var data = await _serviceRepository.Update(ServiceMapper.Map(service)); return(service); }
public static List <SeventyPercentClubEntry> MapToDomain(this IList <SeventyPercentClubEntryDto> dtos) => ServiceMapper.Map <List <SeventyPercentClubEntry> >(dtos);
public SensorModel GetByApartmentId(Guid id) { return(ServiceMapper.Map <SensorModel>(Repository.Filter(s => s.ApartmentId == id).FirstOrDefault())); }
public static List <SeventyPercentClubEntryDto> MapToDto(this IList <SeventyPercentClubEntry> domains) => ServiceMapper.Map <List <SeventyPercentClubEntryDto> >(domains);