public BaseResponse DeleteOrder(OrderModelRequest entity) { try { var orderEntity = entity.MapTo<OrderEntity>(); orderRepository.DeleteOrder(orderEntity); return new BaseResponse { IsSuccess = true }; } catch (Exception ex) { return new BaseResponse { IsSuccess = false, Msg = ex.Message }; } }
public OrderModelResponse AddOrder(OrderModelRequest entity) { try { var orderEntity = entity.MapTo<OrderEntity>(); long id = orderRepository.AddOrder(orderEntity); return id > 0 ? new OrderModelResponse { OrderId = id, IsSuccess = true } : new OrderModelResponse { IsSuccess = false, OrderId = 0 }; } catch(Exception ex) { return new OrderModelResponse { OrderId = 0, IsSuccess = false, Msg = ex.Message }; } }
public BaseResponse UpdateOrder(OrderModelRequest entity) { try { var orderEntity = entity.MapTo<OrderEntity>(); var ordermodel = orderRepository.GetOrder(orderEntity.OrderId); if (ordermodel == null) return new BaseResponse { IsSuccess = false, Msg = "can not find mddel" }; bool result = orderRepository.UpdateOrder(ordermodel); return result ? new BaseResponse { IsSuccess = true } : new BaseResponse { IsSuccess = false}; } catch (Exception ex) { return new BaseResponse { IsSuccess = false, Msg = ex.Message }; } }
public OrderModelResponse GetOrder(OrderModelRequest entity) { try { OrderEntity order = orderRepository.GetOrder(entity.OrderId); return order.MapTo<OrderModelResponse>(); } catch (Exception) { return null; } }