public async Task <Repartidor> CreateRepartidor(Repartidor repartidor) { var repartidorEntity = mapper.Map <RepartidorEntity>(repartidor); ARBRepository.CreateRepartidor(repartidorEntity); if (await ARBRepository.SaveChangesAsync()) { return(mapper.Map <Repartidor>(repartidorEntity)); } throw new Exception("there where and error with the DB"); }
public async Task <Destinatario> CreateDestinatario(string userId, Destinatario destinatario) { destinatario.UsuarioId = userId; destinatario.latitude = "NoTiene"; destinatario.longitude = "NoTiene"; await validateUserId(userId); var destinatarioEntity = mapper.Map <DestinatarioEntity>(destinatario); ARBRepository.CreateDestinatario(destinatarioEntity); if (await ARBRepository.SaveChangesAsync()) { return(mapper.Map <Destinatario>(destinatarioEntity)); } throw new Exception("there where and error with the DB"); }
public async Task <Pedido> CreatePedido(string userId, Pedido pedido) { pedido.UsuarioId = userId; pedido.Status = "Creado"; pedido.RepartidorId = 1; await validateUserId(userId); var pedidoEntity = mapper.Map <PedidoEntity>(pedido); ARBRepository.CreatePedido(pedidoEntity); if (await ARBRepository.SaveChangesAsync()) { return(mapper.Map <Pedido>(pedidoEntity)); } throw new Exception("there where and error with the DB"); }
public async Task <bool> DeleteUsuarioAsync(string id) { await ARBRepository.DeleteUsuarioAsync(id); if (await ARBRepository.SaveChangesAsync()) { return(true); } return(false); }
public async Task <SolicitudUbicacion> UpdateSolicitudAsync(int destinatarioId, string id, SolicitudUbicacion solicitud) { if (id != solicitud.Id) { throw new NotFoundItemException($"not found solicitud with id:{id}"); } await validateDestinoId(destinatarioId); solicitud.Id = id; solicitud.isEdited = true; var solicitudEntity = mapper.Map <SolicitudUbicacionEntity>(solicitud); ARBRepository.UpdateSolicitudAsync(solicitudEntity); if (await ARBRepository.SaveChangesAsync()) { return(mapper.Map <SolicitudUbicacion>(solicitudEntity)); } throw new Exception("there were an error with the BD"); }