Exemple #1
0
        public static ReportKeyValueListResponseFloatDto GetSuperUserSellerReportDelivered(SuperUserReportSellerDeliveredRequest request)
        {
            ReportKeyValueListResponseFloatDto response = new ReportKeyValueListResponseFloatDto();

            try
            {
                if (!SuperUserServices.CheckSuperUser(request.user_id, request.auth_token, response))
                {
                    response.message = MessagesSource.GetMessage("invalid.super.user");
                    return(response);
                }

                SellerReportDeliveredRequest req = new SellerReportDeliveredRequest
                {
                    entity_id       = request.agency_id,
                    periodical_data = request.periodical_data,
                    for_role        = UserType.SuperUser
                };

                return(ReportsServices.GetSellerReportSellerReportDelivered(req));
            }
            catch (Exception e)
            {
                response.MakeExceptionResponse(e);
                return(response);
            }
        }
        public static GetSuperUserDetailsResponse GetDetails(GetSuperUserDetailsRequest request)
        {
            GetSuperUserDetailsResponse response = new GetSuperUserDetailsResponse();
            SuperAdmin superuser = null;

            try
            {
                if (!SuperUserServices.CheckSuperUser(request.user_id, request.auth_token, response))
                {
                    response.message = MessagesSource.GetMessage("invalid.super.user");
                    return(response);
                }
                using (SuperUserDao dao = new SuperUserDao())
                {
                    superuser = dao.FindById(request.user_id);
                    response.super_user_details = new SuperUserDetailsDto();
                    response.super_user_details.super_user_id    = superuser.SAdminID;
                    response.super_user_details.profile_image    = ImagePathService.superUserImagePath + superuser.ProfileImage;
                    response.super_user_details.super_user_name  = superuser.FullName;
                    response.super_user_details.mobile_number    = superuser.MobileNum;
                    response.super_user_details.super_user_email = superuser.Email;
                    response.code         = 0;
                    response.has_resource = 1;
                    response.message      = MessagesSource.GetMessage("superuser.details");
                    return(response);
                }
            }

            catch (Exception ex)
            {
                response.MakeExceptionResponse(ex);
                return(response);
            }
        }
Exemple #3
0
        public static GetAgencyNameResponse GetAgencyNames(GetAgencyNameRequest request)
        {
            GetAgencyNameResponse response = new GetAgencyNameResponse();

            try
            {
                if (!SuperUserServices.CheckSuperUser(request.user_id, request.auth_token, response))
                {
                    response.message = MessagesSource.GetMessage("invalid.super.user");
                    return(response);
                }
                response.agency_names = new List <GetAgencyNameDto>();
                using (AgencyDao dao = new AgencyDao())
                {
                    var agencyList = dao.GetAgencies();
                    if (agencyList != null && agencyList.Count > 0)
                    {
                        response.agency_names = agencyList.Select(r => new GetAgencyNameDto
                        {
                            agency_id   = r.AgenID,
                            agency_name = r.AgencyName
                        }).ToList();
                    }
                    response.code         = 0;
                    response.has_resource = 1;
                    response.message      = MessagesSource.GetMessage("agencies.listed");
                    return(response);
                }
            }
            catch (Exception ex)
            {
                response.MakeExceptionResponse(ex);
                return(response);
            }
        }
        public static ResponseDto ChangeProfile(ChangeProfileSuperUserRequest request)
        {
            request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number);
            ResponseDto response  = new ResponseDto();
            SuperAdmin  superuser = null;

            try
            {
                if (!SuperUserServices.CheckSuperUser(request.user_id, request.auth_token, response))
                {
                    response.message = MessagesSource.GetMessage("invalid.super.user");
                    return(response);
                }
                using (SuperUserDao dao = new SuperUserDao())
                {
                    superuser          = dao.FindById(request.user_id);
                    superuser.FullName = request.super_user_name;
                    //superuser.MobileNum = request.mobile_number;
                    //superuser.ProfileImage = request.profile_image;//Commented bcz image is uploading as multipart
                    superuser.Email = request.super_user_email;
                    dao.Update(superuser);
                    response.code         = 0;
                    response.has_resource = 0;
                    response.message      = MessagesSource.GetMessage("profile.changed");
                    return(response);
                }
            }
            catch (Exception ex)
            {
                response.MakeExceptionResponse(ex);
                return(response);
            }
        }
        public static bool CheckSuperUser(string mobilenumber)
        {
            SuperAdmin superuser = SuperUserServices.GetAuthUserbyMobileNumber(mobilenumber);

            if (superuser == null)
            {
                return(false);
            }
            return(true);
        }
        public static bool CheckSuperUser(int userId, string authToken, ResponseDto response)
        {
            SuperAdmin superuser = SuperUserServices.GetAuthUser(userId, authToken, response);

            if (superuser == null || superuser.AccToken != authToken)
            {
                return(false);
            }
            return(true);
        }
Exemple #7
0
        public static GetDriverNameResponse GetDriversByAgentBoss(GetDriverNameRequest request)
        {
            GetDriverNameResponse response = new GetDriverNameResponse();

            try
            {
                if (request.is_boss)
                {
                    if (!AgentBossServices.CheckAgentBoss(request.user_id, request.auth_token, response))
                    {
                        return(response);
                    }
                }
                else
                {
                    if (!SuperUserServices.CheckSuperUser(request.user_id, request.auth_token, response))
                    {
                        return(response);
                    }
                }
                response.driver_names = new List <GetDriverNameDto>();
                using (OrderDao dao = new OrderDao())
                {
                    var driverList = dao.GetDriversByAgentBoss(request.is_boss ? request.user_id : 0);
                    if (driverList != null && driverList.Count > 0)
                    {
                        response.driver_names = driverList.Select(r => new GetDriverNameDto
                        {
                            driver_id   = r.DrvrID,
                            driver_name = r.DriverName
                        }).ToList();
                    }
                    response.code         = 0;
                    response.has_resource = 1;
                    response.message      = MessagesSource.GetMessage("boss.drv.listed");
                    return(response);
                }
            }
            catch (Exception ex)
            {
                response.MakeExceptionResponse(ex);
                return(response);
            }
        }
Exemple #8
0
        public static SUserSellerRptResponse GetSellerReportBySuperUser(SUserSellerRptRequest request)
        {
            SUserSellerRptResponse response = new SUserSellerRptResponse();

            try
            {
                var productIdList = request.products.Select(x => x.product_id).ToList();
                if (!SuperUserServices.CheckSuperUser(request.user_id, request.auth_token, response))
                {
                    response.message = MessagesSource.GetMessage("invalid.super.user");
                    return(response);
                }
                response.sales_details = new List <SUserSellerRptDto>();
                using (OrderDao dao = new OrderDao())
                {
                    int periodRange = Common.GetAppSetting <int>(APPSETTING_REPORTPERIOD_RANGE, 6);

                    if (productIdList != null && productIdList.Count > 0)
                    {
                        string productIds = string.Join(",", productIdList.Select(n => n.ToString()).ToArray());

                        var sellerRpt = dao.GetSellerReportBySUser(request.user_id, request.total_type, request.periodical_data, periodRange, request.number_of_products, productIds, request.agency_id);
                        if (sellerRpt != null && sellerRpt.Count > 0)
                        {
                            response.sales_details = sellerRpt.Select(r => new SUserSellerRptDto
                            {
                                key   = r.Period,
                                value = r.Value.ToDecimal()
                            }).ToList();
                        }
                    }
                    response.code         = 0;
                    response.has_resource = 1;
                    response.message      = MessagesSource.GetMessage("suser.sales.report");
                    return(response);
                }
            }
            catch (Exception ex)
            {
                response.MakeExceptionResponse(ex);
                return(response);
            }
        }
        //public static ResendOtpResponse ResendOtp(ResendOtpRequest request)
        //{
        //    ResendOtpResponse response = new ResendOtpResponse();
        //    response.otp_details = new OtpDetailsDto();
        //    SuperAdmin superuser = null;
        //    try
        //    {
        //        if (!SuperUserServices.CheckSuperUser(request.mobile_number))
        //        {
        //            response.message = MessagesSource.GetMessage("no.super.user");
        //            return response;
        //        }
        //        using (SuperUserDao userDao = new SuperUserDao())
        //        {

        //            superuser = userDao.FindByMobileNumber(request.mobile_number);
        //        }
        //        OTPServices.ResendOTP(superuser.SAdminID, request.mobile_number, "A");
        //        response.code = 0;
        //        response.has_resource = 1;
        //        response.message = MessagesSource.GetMessage("otp.resent");
        //        response.otp_details.send_otp = 1;
        //        return response;
        //    }
        //    catch (Exception ex)
        //    {
        //        response.MakeExceptionResponse(ex);
        //        return response;
        //    }
        //}
        public static ResponseDto ResetPassword(ResetPasswordRequest request)
        {
            ResponseDto response            = new ResponseDto();
            SuperAdmin  superuser           = null;
            string      newPasswordHash     = TokenGenerator.GetHashedPassword(request.new_password, 49);
            string      confirmPasswordHash = TokenGenerator.GetHashedPassword(request.confirm_password, 49);

            try
            {
                if (!SuperUserServices.CheckSuperUser(request.mobile_number))
                {
                    response.message = MessagesSource.GetMessage("no.super.user");
                    return(response);
                }
                using (SuperUserDao dao = new SuperUserDao())
                {
                    superuser = dao.FindByMobileNumber(request.mobile_number);
                    //agentBoss = dao.FindById(request.user_id);
                    if (newPasswordHash == confirmPasswordHash)
                    {
                        superuser.Password = TokenGenerator.GetHashedPassword(request.new_password, 49);
                        dao.Update(superuser);
                        response.code         = 0;
                        response.has_resource = 0;
                        response.message      = MessagesSource.GetMessage("passwd.reset");
                        return(response);
                    }
                }
                response.code         = 1;
                response.has_resource = 0;
                response.message      = MessagesSource.GetMessage("exception");
                return(response);
            }
            catch (Exception ex)
            {
                response.MakeExceptionResponse(ex);
                return(response);
            }
        }
        //public static ForgotPasswordResponse ForgotPassword(ForgotPasswordRequest request)
        //{
        //    ForgotPasswordResponse response = new ForgotPasswordResponse();
        //    string newPassword = "******"; //TODO change to generation
        //                                 //TokenGenerator.GenerateResetPassword();
        //    SuperAdmin superuser = null;
        //    try
        //    {
        //        using (SuperUserDao dao = new SuperUserDao())
        //        {
        //            superuser = dao.FindByMobileNumber(request.mobile_number);
        //            if (superuser == null)
        //            {
        //                MakeNouserResponse(response);
        //                return response;
        //            }
        //            superuser.Password = TokenGenerator.GetHashedPassword(newPassword, 49);
        //            dao.Update(superuser);
        //            OTPServices.SendPasswordMessage(superuser.MobileNum, newPassword);
        //            response.code = 0;
        //            response.has_resource = 1;
        //            response.reset_password = new ResetPasswordDto();
        //            response.reset_password.password_otp_sent = 1;
        //            response.reset_password.password_reset = 1;
        //            response.message = MessagesSource.GetMessage("passwd.reset");
        //            return response;
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        response.MakeExceptionResponse(ex);
        //        return response;
        //    }
        //}

        public static ResponseDto ChangePassword(ChangePasswordSuperUserRequest request)
        {
            ResponseDto response        = new ResponseDto();
            SuperAdmin  superuser       = null;
            string      oldPasswordHash = TokenGenerator.GetHashedPassword(request.old_password, 49);

            try
            {
                if (!SuperUserServices.CheckSuperUser(request.user_id, request.auth_token, response))
                {
                    response.message = MessagesSource.GetMessage("no.super.user");
                    return(response);
                }
                using (SuperUserDao dao = new SuperUserDao())
                {
                    superuser = dao.FindById(request.user_id);
                    if (superuser.Password == oldPasswordHash)
                    {
                        superuser.Password = TokenGenerator.GetHashedPassword(request.new_password, 49);
                        dao.Update(superuser);
                        response.code         = 0;
                        response.has_resource = 0;
                        response.message      = MessagesSource.GetMessage("password.changed");
                        return(response);
                    }
                }
                response.code         = 1;
                response.has_resource = 0;
                response.message      = MessagesSource.GetMessage("exception");
                return(response);
            }
            catch (Exception ex)
            {
                response.MakeExceptionResponse(ex);
                return(response);
            }
        }
Exemple #11
0
        public static SUserReviewReasonResponse GetSUserReviewReasonReport(SUserReviewReasonRequest request)
        {
            SUserReviewReasonResponse response = new SUserReviewReasonResponse();

            try
            {
                if (!SuperUserServices.CheckSuperUser(request.user_id, request.auth_token, response))
                {
                    response.message = MessagesSource.GetMessage("invalid.super.user");
                    return(response);
                }
                response.service_reason_rating = new List <SUserReviewReasonDto>();
                using (OrderDao dao = new OrderDao())
                {
                    int periodRange   = Common.GetAppSetting <int>(APPSETTING_REPORTPERIOD_RANGE, 6);
                    var reportDetails = dao.GetReviewReasonBySUser(request.user_id, request.agency_id, request.periodical_data, periodRange);
                    if (reportDetails != null && reportDetails.Count > 0)
                    {
                        response.service_reason_rating = reportDetails.Select(r => new SUserReviewReasonDto
                        {
                            key   = r.ReasonText,
                            value = r.Value.ToDecimal()
                        }).ToList();
                    }
                    response.code         = 0;
                    response.has_resource = 1;
                    response.message      = MessagesSource.GetMessage("suser.rating.report");
                    return(response);
                }
            }
            catch (Exception ex)
            {
                response.MakeExceptionResponse(ex);
                return(response);
            }
        }
Exemple #12
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);
        }
Exemple #13
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);
        }