public static ResponseDto ChangeProfile(ChangeProfileAgentBossRequest request) { request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number); ResponseDto response = new ResponseDto(); AgentBoss agentBoss = null; try { if (!AgentBossServices.CheckAgentBoss(request.user_id, request.auth_token, response)) { return(response); } using (AgentBossDao dao = new AgentBossDao()) { agentBoss = dao.FindById(request.user_id); agentBoss.OwnerName = request.agent_boss_name; //agentBoss.MobileNumber = request.mobile_number; //agentBoss.ProfileImage = request.profile_image; //Commented bcz image is uploading as multipart agentBoss.Email = request.agent_boss_email; dao.Update(agentBoss); response.code = 0; response.has_resource = 1; response.message = MessagesSource.GetMessage("profile.changed"); return(response); } } catch (Exception ex) { response.MakeExceptionResponse(ex); return(response); } }
public static GetAgentBossDetailsResponse GetDetails(GetAgentBossDetailsRequest request) { GetAgentBossDetailsResponse response = new GetAgentBossDetailsResponse(); AgentBoss agentBoss = null; try { if (!AgentBossServices.CheckAgentBoss(request.user_id, request.auth_token, response)) { return(response); } using (AgentBossDao dao = new AgentBossDao()) { agentBoss = dao.FindById(request.user_id); response.agent_boss_details = new AgentBossMoreDetailsDto(); response.agent_boss_details.agent_boss_id = agentBoss.AbosID; response.agent_boss_details.profile_image = ImagePathService.agentBossImagePath + agentBoss.ProfileImage; response.agent_boss_details.agent_boss_name = agentBoss.OwnerName; response.agent_boss_details.mobile_number = agentBoss.MobileNumber; response.agent_boss_details.agent_boss_email = agentBoss.Email; response.code = 0; response.has_resource = 1; response.message = MessagesSource.GetMessage("admin.boss.details"); return(response); } } catch (Exception ex) { response.MakeExceptionResponse(ex); return(response); } }
public static ReportKeyValueListResponseFloatDto GetAgentBossSellerReportDelired(AgentBossReportSellerDeliveredRequest request) { ReportKeyValueListResponseFloatDto response = new ReportKeyValueListResponseFloatDto(); try { if (!AgentBossServices.CheckAgentBoss(request.user_id, request.auth_token, response)) { response.message = MessagesSource.GetMessage("invalid.agentboss"); return(response); } SellerReportDeliveredRequest req = new SellerReportDeliveredRequest { entity_id = request.driver_id, periodical_data = request.periodical_data, for_role = UserType.AgentBoss }; return(ReportsServices.GetSellerReportSellerReportDelivered(req)); } catch (Exception e) { response.MakeExceptionResponse(e); return(response); } }
public static ABossReviewReasonResponse GetReviewReasonByAgentBoss(ABossReviewReasonRequest request) { ABossReviewReasonResponse response = new ABossReviewReasonResponse(); try { if (!AgentBossServices.CheckAgentBoss(request.user_id, request.auth_token, response)) { return(response); } response.service_reason_rating = new List <ABossReviewReasonDto>(); using (OrderDao dao = new OrderDao()) { int periodRange = Common.GetAppSetting <int>(APPSETTING_REPORTPERIOD_RANGE, 6); var reportDetails = dao.GetReviewReasonByAgentBoss(request.user_id, request.driver_id, request.periodical_data, periodRange); if (reportDetails != null && reportDetails.Count > 0) { response.service_reason_rating = reportDetails.Select(r => new ABossReviewReasonDto { key = r.ReasonText, value = r.Value.ToDecimal() }).ToList(); } response.code = 0; response.has_resource = 1; response.message = MessagesSource.GetMessage("boss.rating.report"); return(response); } } catch (Exception ex) { response.MakeExceptionResponse(ex); return(response); } }
public static bool CheckAgentBossNotAuthToken(int userId, ResponseDto response) { AgentBoss agentBoss = AgentBossServices.GetAuthAgentBossNotAuthToken(userId, response); if (agentBoss == null) { return(false); } return(true); }
public static bool CheckAgentBoss(int userId, string authToken, ResponseDto response) { AgentBoss agentBoss = AgentBossServices.GetAuthAgentBoss(userId, authToken, response); if (agentBoss == null || agentBoss.AccToken != authToken) { return(false); } return(true); }
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); } }
public static ABossSellerRptResponse GetSellerReportByAgentBoss(ABossSellerRptRequest request) { var productIdList = request.products.Select(x => x.product_id).ToList(); ABossSellerRptResponse response = new ABossSellerRptResponse(); try { if (!AgentBossServices.CheckAgentBoss(request.user_id, request.auth_token, response)) { return(response); } response.sales_details = new List <ABossSellerRptDto>(); 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.GetSellerReportByAgentBoss(request.user_id, request.total_type, request.periodical_data, periodRange, productIds); if (sellerRpt != null && sellerRpt.Count > 0) { response.sales_details = sellerRpt.Select(r => new ABossSellerRptDto { key = r.Period, value = r.Value.ToDecimal() }).ToList(); } } response.code = 0; response.has_resource = 1; response.message = MessagesSource.GetMessage("boss.sales.report"); return(response); } } catch (Exception ex) { response.MakeExceptionResponse(ex); return(response); } }
public static ResponseDto ChangePassword(ChangePasswordAgentBossRequest request) { ResponseDto response = new ResponseDto(); AgentBoss agentBoss = null; string oldPasswordHash = TokenGenerator.GetHashedPassword(request.old_password, 49); try { if (!AgentBossServices.CheckAgentBoss(request.user_id, request.auth_token, response)) { MakeNouserResponse(response); return(response); } using (AgentBossDao dao = new AgentBossDao()) { agentBoss = dao.FindById(request.user_id); if (agentBoss.Password == oldPasswordHash) { agentBoss.Password = TokenGenerator.GetHashedPassword(request.new_password, 49); dao.Update(agentBoss); response.code = 0; response.has_resource = 1; 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); } }
public Dictionary <string, object> UploadProfilePicture(HttpRequest httpRequest, int userType) { string message = string.Empty; Dictionary <string, object> dict = new Dictionary <string, object>(); string _imgname = ""; try { if (httpRequest.Files.Count > 0) { foreach (string file in httpRequest.Files) { var postedFile = httpRequest.Files[file]; if (postedFile != null && postedFile.ContentLength > 0) { int MaxContentLength = 1024 * 1024 * 5; //5 MB IList <string> AllowedFileExtensions = new List <string> { ".jpg", ".gif", ".png" }; var ext = postedFile.FileName.Substring(postedFile.FileName.LastIndexOf('.')); var extension = ext.ToLower(); if (!AllowedFileExtensions.Contains(extension)) { message = string.Format("Please Upload image of type .jpg,.gif,.png."); dict.Add("error", "0"); dict.Add("message", message); } else if (postedFile.ContentLength > MaxContentLength) { message = string.Format("Please Upload a file upto 1 mb."); dict.Add("error", "0"); dict.Add("message", message); } else { string path = HttpContext.Current.Server.MapPath("~/extfiles/profile/"); int userId = 0; if (httpRequest.Form["user_id"] != null) { userId = httpRequest.Form["user_id"].ToInt(); } string auth_token = string.Empty; if (httpRequest.Form["auth_token"] != null) { auth_token = httpRequest.Form["auth_token"].ToString(); } if (userId > 0 && userType > 0) { bool userExist = false; switch ((UserType)userType) { case UserType.SuperUser: path = HttpContext.Current.Server.MapPath("~/extfiles/profile/superuser/"); userExist = SuperUserServices.CheckSuperUser(userId, auth_token, null); break; case UserType.AgentBoss: path = HttpContext.Current.Server.MapPath("~/extfiles/profile/agentboss/"); userExist = AgentBossServices.CheckAgentBoss(userId, auth_token, null); break; case UserType.AgentAdmin: path = HttpContext.Current.Server.MapPath("~/extfiles/profile/agentadmin/"); userExist = AgentAdminServices.CheckAdmin(userId, auth_token, null); break; case UserType.Driver: path = HttpContext.Current.Server.MapPath("~/extfiles/profile/driver/"); userExist = DriverServices.CheckAuthDriver(userId, auth_token); break; case UserType.Consumer: path = HttpContext.Current.Server.MapPath("~/extfiles/profile/customer/"); userExist = _userServices.CheckAuthUser(userId, auth_token); break; } if (!userExist) { message = string.Format("Invalid User"); dict.Add("error", "0"); dict.Add("message", message); } if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } _imgname = string.Format("ProfileImg_{0}{1}", Guid.NewGuid().ToString(), extension); var _comPath = string.Format("{0}{1}", path, _imgname); postedFile.SaveAs(_comPath); } else { message = string.Format("userId or userType cannot be empty"); dict.Add("error", "0"); dict.Add("message", message); } dict.Add("user_id", userId); dict.Add("auth_token", auth_token); } } dict.Add("success", "1"); dict.Add("message", _imgname); } } else { message = string.Format("Please Upload a image."); dict.Add("error", "0"); dict.Add("message", message); } return(dict); } catch (Exception ex) { dict.Add("error", "ex"); dict.Add("message", ex.Message); return(dict); } }
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 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); }