Ejemplo n.º 1
0
        public InfoBannerResponse GetInfoBanner(GetInfoBannerRequest request)
        {
            InfoBannerResponse response = new InfoBannerResponse();

            try
            {
                switch (request.user_type)
                {
                case (int)UserType.SuperUser:
                    if (!SuperUserServices.CheckSuperUser(request.user_id, request.auth_token, response))
                    {
                        response.message = MessagesSource.GetMessage("invalid.super.user");
                        return(response);
                    }
                    break;

                case (int)UserType.AgentBoss:
                    if (!AgentBossServices.CheckAgentBoss(request.user_id, request.auth_token, response))
                    {
                        return(response);
                    }
                    break;

                case (int)UserType.AgentAdmin:
                    if (!AgentAdminServices.CheckAdmin(request.user_id, request.auth_token, response))
                    {
                        return(response);
                    }
                    break;

                case (int)UserType.Driver:
                    if (!DriverServices.CheckAuthDriver(request.user_id, request.auth_token))
                    {
                        _userServices.MakeNouserResponse(response);
                        return(response);
                    }
                    break;

                case (int)UserType.Consumer:
                    if (!_userServices.CheckAuthUser(request.user_id, request.auth_token))
                    {
                        _userServices.MakeNouserResponse(response);
                        return(response);
                    }
                    break;

                default:
                {
                    response.has_resource = 0;
                    response.code         = 1;
                    response.message      = MessagesSource.GetMessage("invalid.user.type");
                    return(response);
                }
                }

                using (PromoDao dao = new PromoDao())
                {
                    List <PromoInfo> bList = dao.GetInfoBanners();
                    if (bList.Count <= 0)
                    {
                        response.has_resource = 1;
                        response.code         = 0;
                        response.message      = MessagesSource.GetMessage("promo.info.not.found");
                        return(response);
                    }
                    InfoBannerDto[] promoDtos = new InfoBannerDto[bList.Count()];
                    for (int i = 0; i < bList.Count; i++)
                    {
                        InfoBannerDto dto = new InfoBannerDto();
                        PromoHelper.CopyFromEntity(dto, bList[i]);
                        promoDtos[i] = dto;
                    }
                    response.info_banners = promoDtos;
                    response.has_resource = 1;
                    response.code         = 0;
                    response.message      = MessagesSource.GetMessage("promo.info.found");
                }
            }
            catch (Exception ex)
            {
                response.MakeExceptionResponse(ex);
            }

            return(response);
        }
        public ConfirmTeleOrderResponse ConfirmTeleOrder(ConfirmTeleOrderRequest request)
        {
            ConfirmTeleOrderResponse response = new ConfirmTeleOrderResponse();

            try
            {
                if (!AgentAdminServices.CheckAdmin(request.user_id, request.auth_token, response))
                {
                    return(response);
                }
                using (TeleOrderDao dao = new TeleOrderDao())
                {
                    TeleOrder order = dao.FindById(request.order_id, true);
                    if (order == null)
                    {
                        MakeNoTeleOrderFoundResponse(response);
                        return(response);
                    }
                    order.StatusId = OrdersServices.ID_ORDER_ACCEPTED;//2;
                    order.DrvrID   = request.driver_id;
                    //Driver drv = order.Driver;
                    //int agId = drv.AgenID;
                    Driver drv = null;
                    using (DriverDao ddao = new DriverDao())
                    {
                        drv = ddao.FindById(request.driver_id);
                        if (drv == null)
                        {
                            DriverServices.MakeNoDriverResponse(response);
                            return(response);
                        }
                        TeleOrderDelivery odel = new TeleOrderDelivery();
                        odel.DrvrID       = drv.DrvrID;
                        odel.AgadmID      = request.user_id;
                        odel.CreatedDate  = DateTime.Now;
                        odel.DeliveryDate = order.DeliveryDate;
                        odel.AcceptedDate = DateTime.Now;
                        odel.StatusId     = OrdersServices.DELIVERY_STATUS_ASSIGNED;//1;
                        odel.TeleOrder    = order;
                        order.TeleOrderDeliveries.Add(odel);
                    }
                    lock (InvoiceService.monitor)
                    {
                        string invNo = InvoiceService.GenerateInvoiceNumber(drv.AgenID);
                        order.InvoiceNumber = invNo;
                        dao.Update(order);
                    }
                    TeleOrderHelper.CopyFromEntity(response, order);
                    using (ConsumerReviewDao conReviewDao = new ConsumerReviewDao())
                    {
                        List <ConsumerReview> conReview = new List <ConsumerReview>();
                        conReview = conReviewDao.GetReviewByDriver(request.driver_id);
                        response.orders.driver.driver_rating = conReview.Count > 0 ? Convert.ToDecimal(conReview.Average(x => x.Rating)) : 0;
                    }

                    if (order.DeliveryDate.HasValue && order.DeliveryDate.Value.ToShortDateString() == DateTime.Now.ToShortDateString())
                    {
                        int orderCount = dao.GetAssignedOrderCount(request.driver_id, OrdersServices.ID_ORDER_ACCEPTED);
                        using (OrderDao ordDao = new OrderDao())
                        {
                            orderCount += ordDao.GetAssignedOrderCount(request.driver_id, OrdersServices.ID_ORDER_ACCEPTED);
                        }
                        _orderService.ReadAndSendPushNotification(OrdersServices.APPSETTING_MSG_TO_ASSIGNED_DRIVER, OrdersServices.APPSETTING_TITLE_FOR_ASSIGNED_DRIVER, drv.AppToken, request.order_id, request.driver_id, orderCount, PushMessagingService.APPSETTING_APPLICATION_ID_DRIVER, PushMessagingService.APPSETTING_SENDER_ID_DRIVER, (int)PushMessagingService.PushType.TypeOne);
                    }

                    response.code         = 0;
                    response.has_resource = 1;
                    response.message      = MessagesSource.GetMessage("cnfrm.tele.order");
                }
            }
            catch (Exception ex)
            {
                response.MakeExceptionResponse(ex);
            }

            return(response);
        }
Ejemplo n.º 3
0
        public GetBannerResponse GetBanner(GetBannerRequest request)
        {
            GetBannerResponse response = new GetBannerResponse();

            try
            {
                switch (request.user_type)
                {
                case (int)UserType.SuperUser:
                    if (!SuperUserServices.CheckSuperUser(request.user_id, request.auth_token, response))
                    {
                        response.message = MessagesSource.GetMessage("invalid.super.user");
                        return(response);
                    }
                    break;

                case (int)UserType.AgentBoss:
                    if (!AgentBossServices.CheckAgentBoss(request.user_id, request.auth_token, response))
                    {
                        return(response);
                    }
                    break;

                case (int)UserType.AgentAdmin:
                    if (!AgentAdminServices.CheckAdmin(request.user_id, request.auth_token, response))
                    {
                        return(response);
                    }
                    break;

                case (int)UserType.Driver:
                    if (!DriverServices.CheckAuthDriver(request.user_id, request.auth_token))
                    {
                        _userServices.MakeNouserResponse(response);
                        return(response);
                    }
                    break;

                case (int)UserType.Consumer:
                    if (!_userServices.CheckAuthUser(request.user_id, request.auth_token))
                    {
                        _userServices.MakeNouserResponse(response);
                        return(response);
                    }
                    break;

                default:
                {
                    response.has_resource = 0;
                    response.code         = 1;
                    response.message      = MessagesSource.GetMessage("invalid.user.type");
                    return(response);
                }
                }

                using (PromoDao dao = new PromoDao())
                {
                    GetBannerResponse dto   = new GetBannerResponse();
                    PromoBanner       promo = dao.FindByCategoty(request.category);
                    if (promo == null)
                    {
                        response.has_resource = 1;
                        response.code         = 0;
                        response.message      = MessagesSource.GetMessage("promo.banner.not.found");
                        return(response);
                    }
                    if (promo != null)
                    {
                        PromoHelper.CopyFromEntity(dto, promo);
                    }
                    response              = dto;
                    response.code         = 0;
                    response.has_resource = 1;
                    response.message      = MessagesSource.GetMessage("promo.banner.found");
                }
            }
            catch (Exception ex)
            {
                response.MakeExceptionResponse(ex);
            }

            return(response);
        }