Beispiel #1
0
        public async Task <DobiHomePageResponse> GetDobiHomePageResponse(string dobiId)
        {
            try
            {
                var dobiInformation = await _dobiRepository.GetDobiById(dobiId);

                if (dobiInformation == null || string.IsNullOrWhiteSpace(dobiInformation.DobiId))
                {
                    return(null);
                }
                var newOrderCount = await _orderRepository.GetNewOrderCountByStatus((int)OrderStatus.New);

                var acceptedOrderCount = await _orderRepository.GetNewOrderCountByStatus((int)OrderStatus.Confirmed);

                var deliverableOrderCount = await _orderRepository.GetNewOrderCountByStatus((int)OrderStatus.Deliverable);

                return(new DobiHomePageResponse
                {
                    Name = dobiInformation.Name,
                    Phone = dobiInformation.Phone,
                    Photo = dobiInformation.Photo,
                    DobiId = dobiInformation.DobiId,
                    IcNumber = dobiInformation.IcNumber,
                    DrivingLicense = dobiInformation.DrivingLicense,
                    NewOrderCount = newOrderCount,
                    AcceptedOrderCount = acceptedOrderCount,
                    DeliveravbleOrderCount = deliverableOrderCount
                });
            }
            catch (Exception ex)
            {
                throw new Exception("Error getting dobi home page response" + ex);
            }
        }
Beispiel #2
0
        public async Task <IHttpActionResult> GetDobiById(string dobiId)
        {
            if (string.IsNullOrWhiteSpace(dobiId))
            {
                return(BadRequest("Invalid dobi id."));
            }
            var dobi = await _dobiRepository.GetDobiById(dobiId);

            if (dobi == null)
            {
                return(Ok(new GenericResponse <string>(false, "", "No dobi found")));
            }
            return(Ok(new GenericResponse <Dobi>(true, dobi)));
        }