public ResendOtpResponse ResendOtp(ResendOtpRequest request) { request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number); ResendOtpResponse response = new ResendOtpResponse(); response.otp_details = new OTPDetailsDto(); Driver driver = null; try { using (DriverDao driverDao = new DriverDao()) { driver = driverDao.FindByMobileNumber(request.mobile_number); } if (driver == null) { MakeNoDriverResponse(response); return(response); } OTPServices.ResendOTP(response, driver.MobileNumber, driver.DrvrID, "D"); 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 UpdateProfileResponse UpdateProfile(UpdateProfileRequest request) { request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number); UpdateProfileResponse response = new UpdateProfileResponse(); try { if (!CheckAuthDriver(request.user_id, request.auth_token)) { MakeNoDriverResponse(response); return(response); } using (DriverDao dao = new DriverDao()) { Driver driver = dao.FindById(request.user_id); driver.DriverName = request.driver_name; //driver.MobileNumber = request.mobile_number; //driver.ProfileImage = request.profile_image; //Commented bcz image is uploading as multipart dao.Update(driver); response.code = 0; response.has_resource = 0; response.message = MessagesSource.GetMessage("profile.changed"); return(response); } } catch (Exception ex) { response.MakeExceptionResponse(ex); return(response); } }
public ResponseDto ChangeProfilePhoto(ChangeProfilePhotoRequest request) { ResponseDto response = new ResponseDto(); try { //if (!CheckAuthDriver(request.user_id, request.auth_token)) //{ // MakeNoDriverResponse(response); // return response; //} using (DriverDao dao = new DriverDao()) { Driver driver = dao.FindById(request.user_id); if (driver != null) { driver.ProfileImage = request.profile_image; dao.Update(driver); } response.code = 0; response.has_resource = 0; response.message = MessagesSource.GetMessage("profile.changed"); return(response); } } catch (Exception ex) { response.MakeExceptionResponse(ex); return(response); } }
public ResponseDto ChangePasswordDriver(ChangePasswordDriverRequest request) { ResponseDto response = new ResponseDto(); Driver driver = null; string oldPasswordHash = TokenGenerator.GetHashedPassword(request.old_password, 49); try { using (DriverDao dao = new DriverDao()) { driver = dao.FindById(request.user_id); if (driver.Password == oldPasswordHash) { driver.Password = TokenGenerator.GetHashedPassword(request.new_password, 49); dao.Update(driver); 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("pass.not.chg"); } } catch (Exception ex) { response.MakeExceptionResponse(ex); } return(response); }
public GetAgentDriverResponse GetAgentDriver(GetAgentDriverRequest request) { GetAgentDriverResponse response = new GetAgentDriverResponse(); Driver driver = null; try { if (!CheckAuthDriver(request.user_id, request.auth_token)) { _userServices.MakeNouserResponse(response); return(response); } using (DriverDao dao = new DriverDao()) { driver = dao.FindById(request.user_id); DTOs.Driver.DriverDetailsDto dto = new DTOs.Driver.DriverDetailsDto(); DriverHelper.CopyFromEntity(dto, driver); response.code = 0; response.has_resource = 1; response.driver_details = dto; response.message = MessagesSource.GetMessage("got.agent.driver"); } } catch (Exception ex) { response.MakeExceptionResponse(ex); } return(response); }
public ConfirmPickupOrderResponse ConfirmPickupOrder(ConfirmPickupOrderRequest request) { ConfirmPickupOrderResponse response = new ConfirmPickupOrderResponse(); 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); order.StatusId = OrdersServices.ID_ORDER_CLOSED; string invNo = InvoiceService.GenerateInvoiceNumber(order.AgentAdmin.AgenID); order.InvoiceNumber = invNo; dao.Update(order); dao.Update(order); OrderPickupHelper.CopyFromEntity(response, order); response.code = 0; response.has_resource = 1; response.message = MessagesSource.GetMessage("cnfrm.pickup.order"); } } catch (Exception ex) { response.MakeExceptionResponse(ex); } return(response); }
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 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 ResendOtpResponse ResendOtp(ResendOtpRequest request) //{ // ResendOtpResponse response = new ResendOtpResponse(); // response.otp_details = new OtpDetailsDto(); // Consumer consumer = null; // try // { // using (UserDao userDao = new UserDao()) // { // consumer = GetAuthUser(userDao, request.user_id, request.auth_token); // } // if (consumer == null) // { // MakeNouserResponse(response); // return response; // } // OTPServices.ResendOTP(request.user_id, consumer.PhoneNumber, "C"); // 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 UserExistsResponse CheckUserExists(UserExistsRequest request) { request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number); UserExistsResponse response = new UserExistsResponse(); Consumer consumer = null; try { using (UserDao dao = new UserDao()) { consumer = dao.FindByMobileNumber(request.mobile_number); } if (consumer == null) { MakeNouserResponse(response); return(response); } UsersHelper.CopyFromEntity(response, consumer); response.code = 0; response.has_resource = 1; response.message = MessagesSource.GetMessage("user.found"); return(response); } catch (Exception ex) { response.MakeExceptionResponse(ex); return(response); } }
public GetAddressResponse GetAddress(GetAddressRequest request) { GetAddressResponse response = new GetAddressResponse(); Consumer consumer = null; try { using (UserDao dao = new UserDao()) { consumer = GetAuthUser(dao, request.user_id, request.auth_token, true); if (consumer == null) { MakeNouserResponse(response); return(response); } ConsumerAddress consAddr = consumer.ConsumerAddresses.Where(a => a.AddrID == request.address_id).First(); UserAddressesDto addrDto = new UserAddressesDto(); UsersHelper.CopyFromEntity(addrDto, consAddr, consumer.Name); response.user_address = addrDto; response.has_resource = 1; response.code = 0; response.message = MessagesSource.GetMessage("addr.details"); return(response); } } catch (Exception ex) { response.MakeExceptionResponse(ex); } return(response); }
public static ResendOtpResponse ResendOtp(DTOs.Gen.ResendOtpRequest request) { request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number); ResendOtpResponse response = new ResendOtpResponse(); response.otp_details = new OTPDetailsDto(); AgentAdmin agentAdmin = null; try { using (AgentAdminDao adminDao = new AgentAdminDao()) { // agentBoss = GetAuthAgentBoss(request.user_id, request.auth_token, response); agentAdmin = adminDao.FindByMobileNumber(request.mobile_number); } if (agentAdmin == null) { MakeNouserResponse(response); return(response); } OTPServices.ResendOTP(response, agentAdmin.MobileNumber, agentAdmin.AgadmID, "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 ResendOtpResponse ResendOtp(ResendOtpRequest request) { request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number); ResendOtpResponse response = new ResendOtpResponse(); response.otp_details = new OTPDetailsDto(); SuperAdmin suerUser = null; try { using (SuperUserDao sUserDao = new SuperUserDao()) { suerUser = sUserDao.FindByMobileNumber(request.mobile_number); } if (suerUser == null) { MakeNouserResponse(response); return(response); } OTPServices.ResendOTP(response, suerUser.MobileNum, suerUser.SAdminID, "S"); 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 GetAgentAdminDetailsResponse GetDetails(GetAgentAdminDetailsRequest request) { GetAgentAdminDetailsResponse response = new GetAgentAdminDetailsResponse(); AgentAdmin admin = null; try { if (!AgentAdminServices.CheckAdmin(request.user_id, request.auth_token, response)) { return(response); } using (AgentAdminDao dao = new AgentAdminDao()) { admin = dao.FindById(request.user_id); response.agent_admin_details = new AgentAdminDetailsDto(); response.agent_admin_details.agent_admin_id = admin.AgadmID; response.agent_admin_details.agent_admin_name = admin.AgentAdminName; response.agent_admin_details.mobile_number = admin.MobileNumber; response.agent_admin_details.profile_image = ImagePathService.agentAdminImagePath + admin.ProfileImage; response.agent_admin_details.agent_admin_email = admin.email; response.code = 0; response.has_resource = 1; response.message = MessagesSource.GetMessage("admin.details"); return(response); } } catch (Exception ex) { response.MakeExceptionResponse(ex); 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); } }
public static ResponseDto ChangeProfilePhoto(ChangeProfilePhotoRequest request) { 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); if (superuser != null) { superuser.ProfileImage = request.profile_image; 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 GetUserDetailsResponse GetUserDetails(GetUserDetailsRequest request) { GetUserDetailsResponse response = new GetUserDetailsResponse(); Consumer consumer = null; try { using (UserDao dao = new UserDao()) { consumer = GetAuthUser(dao, request.user_id, request.auth_token, true); if (consumer == null) { MakeNouserResponse(response); return(response); } UsersHelper.CopyFromEntity(response, consumer); response.has_resource = 1; response.code = 0; response.message = MessagesSource.GetMessage("user.details"); 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 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 ResendOtpResponse ResendOtp(ResendOtpRequest request) { request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number); ResendOtpResponse response = new ResendOtpResponse(); response.otp_details = new OTPDetailsDto(); AgentBoss agentBoss = null; try { using (AgentBossDao bossDao = new AgentBossDao()) { agentBoss = bossDao.FindByMobileNumber(request.mobile_number); } if (agentBoss == null) { MakeNouserResponse(response); return(response); } OTPServices.ResendOTP(response, agentBoss.MobileNumber, agentBoss.AbosID, "B"); 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 ResendOtpResponse ResendOtp(ResendOtpRequest request) { request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number); ResendOtpResponse response = new ResendOtpResponse(); response.otp_details = new OTPDetailsDto(); Consumer consumer = null; try { using (UserDao userDao = new UserDao()) { consumer = userDao.FindByMobileNumber(request.mobile_number); } if (consumer == null) { MakeNouserResponse(response); return(response); } OTPServices.ResendOTP(response, consumer.PhoneNumber, consumer.ConsID, "C"); 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 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 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 ResponseDto ChangeProfilePhoto(ChangeProfilePhotoRequest request) { ResponseDto response = new ResponseDto(); AgentAdmin admin = null; try { //if (!AgentAdminServices.CheckAdmin(request.user_id, request.auth_token, response)) //{ // return response; //} using (AgentAdminDao dao = new AgentAdminDao()) { admin = dao.FindById(request.user_id); if (admin != null) { admin.ProfileImage = request.profile_image; dao.Update(admin); } response.code = 0; response.has_resource = 0; response.message = MessagesSource.GetMessage("profile.changed"); return(response); } } catch (Exception ex) { response.MakeExceptionResponse(ex); return(response); } }
public GetAddressesResponse GetAddresses(GetAddressesRequest request) { GetAddressesResponse response = new GetAddressesResponse(); Consumer consumer = null; try { using (UserDao dao = new UserDao()) { consumer = GetAuthUser(dao, request.user_id, request.auth_token, true); if (consumer == null) { MakeNouserResponse(response); return(response); } if (consumer.ConsumerAddresses.Count <= 0 && consumer.ConsumerAddresses.Where(x => x.StatusID == 1).Count() <= 0) { MakeNoAddressResponse(response); return(response); } UsersHelper.CopyFromEntity(response, consumer); response.has_resource = 1; response.code = 0; response.message = MessagesSource.GetMessage("address.details.found"); return(response); } } catch (Exception ex) { response.MakeExceptionResponse(ex); } return(response); }
public static ResponseDto ChangeProfile(ChangeProfileAgentAdminRequest request) { request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number); ResponseDto response = new ResponseDto(); AgentAdmin admin = null; try { if (!AgentAdminServices.CheckAdmin(request.user_id, request.auth_token, response)) { return(response); } using (AgentAdminDao dao = new AgentAdminDao()) { admin = dao.FindById(request.user_id); admin.AgentAdminName = request.agent_admin_name; //admin.MobileNumber = request.mobile_number; //admin.ProfileImage = string.IsNullOrWhiteSpace(request.profile_image) ? admin.ProfileImage : request.profile_image; //Commented bcz image is uploading as multipart admin.email = request.agent_admin_email; dao.Update(admin); 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 void SendOTPForForgotPassword(ForgotPasswordResponse response, string mobileNumber, int userId, string userType) { if (response == null) { response = new ForgotPasswordResponse(); } if (response.reset_password == null) { response.reset_password = new ForgotPasswordDto(); } string otp = SMSService.SendOTP(mobileNumber); if (string.IsNullOrWhiteSpace(otp)) { response.code = 1; response.has_resource = 0; response.message = MessagesSource.GetMessage("otp.not.sent"); return; } if (SaveOTP(otp, userId, userType)) { response.reset_password.new_password_otp_sent = 1; // state that OTP has been sent. } response.code = 0; response.has_resource = 1; response.message = MessagesSource.GetMessage("otp.sent"); }
public static LoginResponse Login(LoginRequest request) { request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number); LoginResponse response = new LoginResponse(); SuperAdmin superuser = null; string hashPassword = TokenGenerator.GetHashedPassword(request.password, 49); try { using (SuperUserDao dao = new SuperUserDao()) { superuser = dao.FindByMobileNumber(request.mobile_number); if (superuser == null) { MakeNouserResponse(response); return(response); } if (hashPassword == superuser.Password) { response.code = 1; response.has_resource = 0; //admin. = request.app_id; superuser.AppToken = request.push_token; superuser.AppID = request.app_id; superuser.LastLogin = DateTime.Now; string authToken = TokenGenerator.GenerateToken(superuser.FullName, superuser.Password, request.mobile_number); superuser.AccToken = authToken; dao.Update(superuser); response.code = 0; SuperUserLoginDto dto = new SuperUserLoginDto(); SuperUserHelper.CopyFromEntity(dto, superuser); SuperUserLoginDetailsDto dtoDetails = new SuperUserLoginDetailsDto(); SuperUserHelper.CopyFromEntity(dtoDetails, superuser); response.user_login = dto; response.super_user_details = dtoDetails; response.has_resource = 1; response.code = 0; response.message = MessagesSource.GetMessage("login.ok"); return(response); } else { response.code = 1; response.has_resource = 0; response.message = MessagesSource.GetMessage("login.fail"); } } } catch (Exception ex) { response.MakeExceptionResponse(ex); } return(response); }
public LoginResponse Login(LoginRequest request) { request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number); LoginResponse response = new LoginResponse(); Consumer consumer = null; string hashPassword = TokenGenerator.GetHashedPassword(request.user_password, 49); try { using (UserDao dao = new UserDao()) { consumer = dao.FindByMobileNumber(request.mobile_number); if (consumer == null) { MakeNouserResponse(response); return(response); } if (hashPassword == consumer.Password) { response.code = 1; response.has_resource = 0; if (consumer.ConsBlocked) { response.message = MessagesSource.GetMessage("user.blocked"); return(response); } if (!consumer.ConsActivated) { response.message = MessagesSource.GetMessage("user.not.active"); return(response); } consumer.AppID = request.app_id; consumer.AppToken = request.push_token; consumer.LastLogin = DateTime.Now; consumer.AccToken = TokenGenerator.GenerateToken(consumer.Name, consumer.Password, consumer.PhoneNumber); dao.Update(consumer); response.code = 0; UsersHelper.CopyFromEntity(response, consumer); response.has_resource = 1; if (response.user_login.allow_login == 1) { response.code = 0; response.message = MessagesSource.GetMessage("login.ok"); return(response); } } } } catch (Exception ex) { response.MakeExceptionResponse(ex); } return(response); }
public static LoginResponse Login(LoginRequest request) { request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number); LoginResponse response = new LoginResponse(); AgentAdmin admin = null; string hashPassword = TokenGenerator.GetHashedPassword(request.password, 49); try { using (AgentAdminDao dao = new AgentAdminDao()) { admin = dao.FindByMobileNumber(request.mobile_number); if (admin == null) { MakeNouserResponse(response); return(response); } if (hashPassword == admin.Password) { response.code = 1; response.has_resource = 0; //admin. = request.app_id; admin.AppToken = request.push_token; admin.AppID = request.app_id; admin.LastLogin = DateTime.Now; string authToken = TokenGenerator.GenerateToken(admin.AgentAdminName, admin.Password, request.mobile_number); admin.AccToken = authToken; dao.Update(admin); response.code = 0; UserLoginDto dto = new UserLoginDto(); AgentHelper.CopyFromEntity(dto, admin); response.user_login = dto; response.has_resource = 1; response.code = 0; response.message = MessagesSource.GetMessage("login.ok"); return(response); } else { response.code = 1; response.has_resource = 0; response.message = MessagesSource.GetMessage("login.fail"); } } } catch (Exception ex) { response.MakeExceptionResponse(ex); } return(response); }
public ResponseDto AddAddress(AddAddressRequest request) { ResponseDto response = new ResponseDto(); Consumer consumer = null; response.has_resource = 0; try { using (UserDao dao = new UserDao()) { consumer = GetAuthUser(dao, request.user_id, request.auth_token, true); if (consumer == null) { MakeNouserResponse(response); return(response); } ConsumerAddress address = new ConsumerAddress(); address.ConsID = request.user_id; UsersHelper.CopyToEntity(address, request); address.CreatedDate = DateTime.Now; address.UpdatedDate = address.CreatedDate; address.StatusID = 1; if (consumer.ConsumerAddresses.Count == 0) { address.IsDefault = true; } else { address.IsDefault = Convert.ToBoolean(request.is_default); if (Convert.ToBoolean(request.is_default)) { foreach (var item in consumer.ConsumerAddresses) { item.IsDefault = false; } dao.Update(consumer); } } dao.AddAddress(address); response.code = 0; response.message = MessagesSource.GetMessage("addr.added"); return(response); } } catch (Exception ex) { response.MakeExceptionResponse(ex); } return(response); }