Ejemplo n.º 1
0
        private DefaultResponse ClientChangePhone(ClientChangeModel model)
        {
            var response = new DefaultResponse();

            try
            {
                AddPhoneRequest request = new AddPhoneRequest
                {
                    ClientID = model.Id,
                    Phone    = Convert.ToInt64(PhoneService.GetPhoneFromStr(model.Phone))
                };
                HttpResponseMessage changeResponse = HttpClientService.PostAsync("api/client/AddPhone", request).Result;
                if (changeResponse.IsSuccessStatusCode)
                {
                    response = changeResponse.Content.ReadAsAsync <DefaultResponse>().Result;
                    return(response);
                }
            }
            catch (Exception e)
            {
                response.ErrorCode = 500;
                response.Message   = e.Message;
            }
            return(response);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Обновляет сущность <paramref name="user" /> из <paramref name="model" />,
        /// </summary>
        /// <param name="user"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public static User UpdateUser(User user, UpdateUserModel model)
        {
            if (model.Email != null)
            {
                user.UserName = model.Email;
            }

            if (model.Phone != null)
            {
                user.UserPhone = PhoneService.PhoneConvert(model.Phone);
            }

            if (model.Name != null)
            {
                user.UserInfo.Name = model.Name;
            }

            if (model.LastName != null)
            {
                user.UserInfo.LastName = model.LastName;
            }

            if (model.Company != null)
            {
                user.UserInfo.Company = model.Company;
            }

            if (model.Position != null)
            {
                user.UserInfo.Position = model.Position;
            }

            return(user);
        }
Ejemplo n.º 3
0
        private bool CheckPhoneOrCardNumberIsFree(string phone, string card)
        {
            if (string.IsNullOrEmpty(phone) && string.IsNullOrEmpty(card))
            {
                return(false);
            }
            LCManager.Infrastructure.Request.GetClientInfoRequest request = new LCManager.Infrastructure.Request.GetClientInfoRequest();
            if (!string.IsNullOrEmpty(card))
            {
                try { request.Card = Convert.ToInt64(card); } catch { }
            }
            if (!string.IsNullOrEmpty(phone))
            {
                try { request.Phone = Convert.ToInt64(PhoneService.GetPhoneFromStr(phone)); } catch { }
            }
            try { request.Operator = Convert.ToInt16(JwtProps.GetOperator()); } catch { }
            HttpResponseMessage response = HttpClientService.PostAsync("api/values/ClientInfo", request).Result;

            if (response.IsSuccessStatusCode)
            {
                LCManager.Infrastructure.Response.GetClientInfoResponse data = response.Content.ReadAsAsync <LCManager.Infrastructure.Response.GetClientInfoResponse>().Result;
                if (data.ErrorCode == 0)
                {
                    return
                        (string.IsNullOrEmpty(data.Name) &&
                         string.IsNullOrEmpty(data.Surname) &&
                         string.IsNullOrEmpty(data.Patronymic) &&
                         data.Id == 0 &&
                         data.Card == 0);
                }
                return(true);
            }
            return(false);
        }
Ejemplo n.º 4
0
 public MainHub(IUserConnectionStorage userConnectionStorage, PhoneService phoneService, IUnitOfWork unitOfWork, IEmailIgnoreNotifierManger emailIgnoreNotifierManger)
 {
     _userConnectionStorage     = userConnectionStorage.ValidateNotDefault(nameof(userConnectionStorage));
     _phoneService              = phoneService.ValidateNotDefault(nameof(phoneService));
     _unitOfWork                = unitOfWork.ValidateNotDefault(nameof(unitOfWork));
     _emailIgnoreNotifierManger = emailIgnoreNotifierManger.ValidateNotDefault(nameof(emailIgnoreNotifierManger));
 }
        public IHttpActionResult Get()
        {
            PhoneService          service = new PhoneService(new BusinessDbContext());
            List <PhoneViewModel> models  = service.GetAll();

            return(Ok(models));
        }
Ejemplo n.º 6
0
        static async Task Main(string[] args)
        {
            string baseDir    = AppDomain.CurrentDomain.BaseDirectory;
            string configPath = AppDomain.CurrentDomain.BaseDirectory + "settings.json";

            if (args.Length > 0)
            {
                configPath = args[0];
            }


            Console.WriteLine("Using settings path: " + configPath);
            if (!File.Exists(configPath))
            {
                Console.WriteLine("Error: Config file cannot be found in the specified path.");
                Console.ReadLine();
                return;
            }

            //setup
            var config = JsonConvert.DeserializeObject <AppSettings>(File.ReadAllText(configPath));

            //check/create logs folder
            if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + Logs.LogFolderName))
            {
                Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + Logs.LogFolderName);
            }

            //services
#if DEBUG
            var logs = Console.Out; //TODO: move to file
#else
            var logs = File.CreateText(baseDir + Logs.LogFolderName + '/' + DateTime.Now.ToString(Logs.LogNameFormat) + Logs.LogFileExtension);
#endif
            var cap   = new AppointmentDBContext(config.CAPDBPath);
            var zoom  = new ZoomService(config.ZoomAPIKey, config.ZoomAPISecret);
            var cache = new MeetingCache(config.CacheFilePath);
            PhoneService.Init(config.TwilioAccountSID, config.TwilioAuthToken);

            //main functionality
            var sync = new MeetingSync(cap, zoom, cache, logs, config);


#if DEBUG
            //test date
            var syncDate = new DateTime(2021, 5, 31);

            //sync appointments
            await sync.SyncAppointments(syncDate, DateTime.MaxValue);
#else
            var syncDate = DateTime.Now.Subtract(DateTime.Now.TimeOfDay);

            //sync appointments
            await sync.SyncAppointments(syncDate, DateTime.MaxValue);
#endif
            //save cache
            cache.RemoveBefore(syncDate.AddDays(-7));
            cache.Dispose();
        }
Ejemplo n.º 7
0
 /// <summary>
 /// <see cref="CustomPhoneAttribute"/>
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public override bool IsValid(object value)
 {
     if (String.IsNullOrEmpty((string)value))
     {
         return(true);
     }
     return(PhoneService.IsPhoneValid((string)value));
 }
Ejemplo n.º 8
0
        public IHttpActionResult Get()
        {
            PhoneService service = new PhoneService(new BusinessDbContext()); // Make a dbcontex connnection
            List<PhoneViewModel> models = service.GetAll(); 

            return Ok(models);

        }
Ejemplo n.º 9
0
        /// <summary>
        /// SMSs the position.
        /// </summary>
        /// <param name="timeout">The timeout.</param>
        /// <returns>Task.</returns>
        private async Task SmsPosition(int timeout = 5000)
        {
            var position = await Geolocator.GetPositionAsync(timeout);

            PhoneService.SendSMS(string.Empty, position.ToUri().ToString());

            Device.OpenUri(position.ToUri());
        }
 public ActionResult Remove(int id)
 {
     if (Session["currentUser"] == null || ((User)Session["currentUser"]).role.name != "ADMIN")
     {
         return(Redirect("~/Login"));
     }
     PhoneService.removeById(id);
     return(Redirect("~/Admin/PhoneManage"));
 }
Ejemplo n.º 11
0
 public BusinessLogic(IRepository repository, PhoneService phoneService, IMemoryCache memoryCache)
 {
     _repo         = repository;
     _phoneService = phoneService;
     map           = new Map();
     validator     = new Validator(phoneService);
     _cache        = memoryCache;
     _cacheService = new CacheService(_cache);
 }
        public ActionResult PhoneManage()
        {
            if (Session["currentUser"] == null || ((User)Session["currentUser"]).role.name != "ADMIN")
            {
                return(Redirect("~/Login"));
            }
            List <Phone> listPhones = PhoneService.SortByName();

            return(View(listPhones));
        }
        public ActionResult Edit(int id)
        {
            if (Session["currentUser"] == null || ((User)Session["currentUser"]).role.name != "ADMIN")
            {
                return(Redirect("~/Login"));
            }
            Phone phone = PhoneService.getPhoneById(id);

            return(View(phone));
        }
Ejemplo n.º 14
0
 public ReviewController(DatabaseContext context)
 {
     _reviewService       = new ReviewService(context);
     _phoneService        = new PhoneService(context);
     _reviewSourceService = new ReviewSourceService(context);
     _phoneIds            = new SortedDictionary <string, int> {
     };
     _sourceIds           = new SortedDictionary <string, int> {
     };
 }
Ejemplo n.º 15
0
        public void PhoneServiceGetData()
        {
            memoryCache = new Mock <IMemoryCache>();

            IPhoneService phoneService = new PhoneService(memoryCache.Object);

            var data = phoneService.GetData("4407492743");

            Assert.AreEqual(30, data.Combinations.Count);
            Assert.AreEqual(30, data.Total);
        }
        public void Test()
        {
            var gpsMock = new GpsMock();

            gpsMock.SetSteps(5000);

            var service = new PhoneService(new ConnectionMock(), gpsMock, null);

            StepStatus met = service.NumberOfStepsMet();

            Assert.AreEqual(met, StepStatus.Met);
        }
Ejemplo n.º 17
0
        public async void PhoneCall(string directionParam)
        {
            var phome = ConvertParameterFromWebView <PhoneCallParameter>(directionParam);

            if (phome != null)
            {
                PhoneService.Call(phome?.PhoneNumber);
            }
            else
            {
                await App.Current.MainPage.DisplayAlert("แจ้งเตือน", "ขออภัย เกิดข้อผิดพลาด", "ปิด");
            }
        }
Ejemplo n.º 18
0
        public async void PhoneCall(string phoneParam)
        {
            var phome = ConvertParameterFromWebView <PhoneCallParameter>(phoneParam);

            if (phome != null)
            {
                PhoneService.Call(phome?.PhoneNumber);
            }
            else
            {
                PageService.DisplayAlert("แจ้งเตือน", "ขออภัย เกิดข้อผิดพลาด", "ปิด");
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Обновляет информацию <paramref name="user" /> из <paramref name="model" />
        /// </summary>
        /// <param name="user"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public static User UpdateInviteUser(User user, UpdateInviteModel model)
        {
            user.UserName  = model.Email;
            user.UserPhone = PhoneService.PhoneConvert(model.Phone);

            user.UserInfo.Name     = model.Name;
            user.UserInfo.LastName = model.LastName;
            user.UserInfo.Company  = model.Company;
            user.UserInfo.Position = model.Position;

            StatusService.ChangeStatus(user, UserStatusType.AcceptInvite);
            return(user);
        }
Ejemplo n.º 20
0
        static void Main(string[] args)
        {
            string baseDir    = AppDomain.CurrentDomain.BaseDirectory;
            string configPath = AppDomain.CurrentDomain.BaseDirectory + "settings.json";

            if (args.Length > 0)
            {
                configPath = args[0];
            }


            Console.WriteLine("Using settings path: " + configPath);
            if (!File.Exists(configPath))
            {
                Console.WriteLine("Error: Config file cannot be found in the specified path.");
                Console.ReadLine();
                return;
            }

            var config   = JsonConvert.DeserializeObject <AppSettings>(File.ReadAllText(configPath));
            var reminder = new ZBAppReminder(config);

            PhoneService.Init(config.TwilioAccountSID, config.TwilioAuthToken);

            //check create logs folder
            if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + Logs.LogFolderName))
            {
                Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + Logs.LogFolderName);
            }

            var tomorrow = DateTime.Now.AddDays(1);

#if DEBUG
            tomorrow        = new DateTime(2021, 5, 31);
            reminder.Output = Console.Out; //For testing output to console
            reminder.CheckSendTextReminders(tomorrow, tomorrow);
            Console.ReadLine();
#else
            try
            {
                reminder.Output = File.CreateText(baseDir + Logs.LogFolderName + '/' + DateTime.Now.ToString(Logs.LogNameFormat) + Logs.LogFileExtension);
                reminder.CheckSendTextReminders(tomorrow, tomorrow);
            }
            catch (Exception ex)
            {
                File.WriteAllText(baseDir + Logs.LogFolderName + @"/Error " + DateTime.Now.ToString(Logs.LogNameFormat) + Logs.LogFileExtension, ex.ToString());
                PhoneService.SendMessage(config.ErrorLogPhone, config.TwilioPhone, ex.ToString());
            }
            reminder.Output.Close();
#endif
        }
Ejemplo n.º 21
0
        public async void ResetSecurityCode_Should_Call_All_Require_Parameters()
        {
            _userPhoneRepositoryMock = new Mock <IUserPhoneRepository>();
            var userPhone = new UserPhone();

            _userPhoneRepositoryMock.Setup(c => c.GetAsync(1234)).ReturnsAsync(userPhone);
            _userPhoneRepositoryMock.Setup(c => c.UpdateAsync(It.IsAny <UserPhone>())).ReturnsAsync(userPhone);
            _userPhoneRepositoryMock.Setup(c => c.SaveChangesAsync()).ReturnsAsync(1);
            _phoneService = new PhoneService(_userManager, _mapperFixture.MapperInstance, _userPhoneRepositoryMock.Object);

            await _phoneService.InsertSecurityCodeAsync(1234, "code");

            _userPhoneRepositoryMock.VerifyAll();
        }
        // GET: Phone
        public ActionResult Index()
        {
            List <Brand>         listAllBrands = BrandService.getAllBrand();
            List <List <Phone> > list          = new List <List <Phone> >();
            List <String>        listBrand     = new List <string>();

            foreach (var brand in listAllBrands)
            {
                list.Add(PhoneService.getPhonesByBrand(brand.id));
                listBrand.Add(brand.name);
            }
            ViewBag.List      = list;
            ViewBag.ListBrand = listBrand;
            return(View());
        }
Ejemplo n.º 23
0
        public void CheckIfBundleOfMinutesExceeded_SecondsLeftInBundle_CorrectBooleanValue()
        {
            //Arrange

            var dataObjectMapperMock           = new Mock <IDataObjectMapper>();
            var subscribersSystemDbContextMock = new Mock <ISubscribersSystemDbContext>();

            var phoneService = new PhoneService(() => subscribersSystemDbContextMock.Object, dataObjectMapperMock.Object);

            //Act
            var result = phoneService.CheckIfBundleOfMinutesExceeded(validPhone.SecondsLeftInBundle);

            //Assert
            Assert.IsFalse(result);
        }
        public ActionResult Edit(int id, String name, double price, String shortDescription, String fullDescription, int brand_id)
        {
            if (Session["currentUser"] == null || ((User)Session["currentUser"]).role.name != "ADMIN")
            {
                return(Redirect("~/Login"));
            }
            Phone phone = PhoneService.getPhoneById(id);

            phone.name             = name;
            phone.price            = price;
            phone.shortDescription = shortDescription;
            phone.fullDescription  = fullDescription;
            phone.brand_id         = brand_id;
            return(Redirect("~/Admin/PhoneManage"));
        }
Ejemplo n.º 25
0
        private void sendUpdated(Transaction appt, CachedMeeting meeting, Employee emp)
        {
            var msg = string.Format(this.updatedMsg, emp.FirstName, meeting.StartTime.ToLocalTime().ToString("g"), meeting.JoinUrl, meeting.Password);

            try
            {
                this.log.WriteLine($"Sending updated text message to {appt.Customer.Telephone}");
                PhoneService.SendMessage(appt.Customer.Telephone, this.fromPhone, msg);
            }
            catch (Exception ex)
            {
                this.log.WriteLine($"Error sending text to {appt.Customer.Telephone} - {appt.Customer.FirstName } {appt.Customer.LastName} ({appt.CustomerID})");
                this.log.WriteLine(ex.Message);
                this.log.WriteLine(ex.StackTrace);
            }
        }
Ejemplo n.º 26
0
        private void sendDeleted(CachedMeeting meeting)
        {
            var msg = string.Format(this.deletedMsg, meeting.StartTime.ToLocalTime().ToString("g"));

            try
            {
                this.log.WriteLine($"Sending deleted text message to {meeting.CustomerPhone}");
                PhoneService.SendMessage(meeting.CustomerPhone, this.fromPhone, msg);
            }
            catch (Exception ex)
            {
                this.log.WriteLine($"Error sending text to {meeting.CustomerPhone}");
                this.log.WriteLine(ex.Message);
                this.log.WriteLine(ex.StackTrace);
            }
        }
Ejemplo n.º 27
0
        public void FormatePhoneNumberLocal()
        {
            //Arrange
            string telephone      = "+923336323900";
            string dialFrom       = "PK";
            string expectedResult = "0333 6323900";

            mockPhoneService.Setup(x => x.FormatePhoneNumberForDisplay(telephone, dialFrom)).Returns(new GenericResponse <ValidatePhoneNumberModel>());

            //Act
            PhoneService phoneServcie = new PhoneService();
            var          result       = phoneServcie.FormatePhoneNumberForDisplay(telephone, dialFrom);

            //Assert

            Assert.AreEqual(expectedResult, result.Data.FormattedNumber);
        }
Ejemplo n.º 28
0
        public void GetPriceOfTheConnection_ValidPhoneAndTimeOfConnection_CorrectValue()
        {
            //Arrange
            const int     TIME_OF_CONNECTION = 50;
            const decimal TOTAL_COST         = 50 * 0.60M / 60;

            var dataObjectMapperMock           = new Mock <IDataObjectMapper>();
            var subscribersSystemDbContextMock = new Mock <ISubscribersSystemDbContext>();

            var phoneService = new PhoneService(() => subscribersSystemDbContextMock.Object, dataObjectMapperMock.Object);

            //Act
            var result = phoneService.GetPriceOfTheConnection(validPhone, TIME_OF_CONNECTION);

            //Assert
            Assert.AreEqual(TOTAL_COST, result);
        }
Ejemplo n.º 29
0
        public AppService(AppDbContext db)
        {
            Phone           = new PhoneService(db, this);
            Company         = new CompanyService(db, this);
            CallRecord      = new CallRecordService(db, this);
            State           = new StateService(db, this);
            SystemSetting   = new SystemSettingService(db, this);
            CostingTemplate = new CostingTemplateService(db, this);
            QuoteTemplate   = new QuoteTemplateService(db, this);
            Quote           = new QuoteService(db, this);
            Costing         = new CostingService(db, this);
            CallScript      = new CallScriptService(db, this);
            CallQuestion    = new CallQuestionService(db, this);
            CallAnswer      = new CallAnswerService(db, this);

            _appDbContext = db;
        }
Ejemplo n.º 30
0
        public async Task <IActionResult> GetPhoneCode(PhoneDto phoneDto)
        {
            Random random    = new Random();
            int    sayi      = random.Next(100000, 999999);
            var    phoneCode = new PhoneNumberCode()
            {
                PhoneNumber = phoneDto.PhoneNumber,
                Code        = sayi
            };

            PhoneService.Send(phoneDto.PhoneNumber, sayi);
            _authRepo.Add(phoneCode);
            if (await _authRepo.SaveAll())
            {
                return(Ok());
            }
            return(BadRequest("Failed to send the code"));
        }
Ejemplo n.º 31
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Xamarin.Forms.Labs.WindowsPhoneDevice" /> class.
        /// </summary>
        private WindowsPhoneDevice()
        {
            Display = new Display();
            PhoneService = new PhoneService();
            Battery = new Battery();

            if (Microsoft.Devices.Sensors.Accelerometer.IsSupported)
            {
                Accelerometer = new Accelerometer();
            }

            if (Microsoft.Devices.Sensors.Gyroscope.IsSupported)
            {
                this.Gyroscope = new Gyroscope();
            }

            MediaPicker = new MediaPicker();
        }
        /// <summary>
        /// Prevents a default instance of the <see cref="WindowsPhoneDevice"/> class from being created.
        /// </summary>
        private WindowsPhoneDevice()
        {
            Display = new Display();
            PhoneService = new PhoneService();
            Battery = new Battery();

            if (DeviceCapabilities.IsEnabled(DeviceCapabilities.Capability.ID_CAP_SENSORS))
            {
                if (Microsoft.Devices.Sensors.Accelerometer.IsSupported)
                {
                    this.Accelerometer = new Accelerometer();
                }

                if (Microsoft.Devices.Sensors.Gyroscope.IsSupported)
                {
                    this.Gyroscope = new Gyroscope();
                }
            }

            //if (DeviceCapabilities.IsEnabled(DeviceCapabilities.Capability.ID_CAP_MEDIALIB_PHOTO))
            //{
            //    MediaPicker = new MediaPicker();
            //}
        }
Ejemplo n.º 33
0
        private void InitServices()
        {
            _dispatchService = IocContainer.GetContainer().Resolve<IDispatcherService>() as DispatcherService;

            _navigationService = IocContainer.GetContainer().Resolve<IExtendedNavigationService>() as ExtendedNavigationService;

            _dialogService = IocContainer.GetContainer().Resolve<IExtendedDialogService>() as ExtendedDialogService;

            _hudService = IocContainer.GetContainer().Resolve<IHudService>() as HudService;

            _browserService = IocContainer.GetContainer().Resolve<IBrowserService>() as BrowserService;

            _geoLocator = IocContainer.GetContainer().Resolve<IGeolocator>() as Geolocator;

            _connectivityService = IocContainer.GetContainer().Resolve<IConnectivityService>() as ConnectivityService;

            _phoneService = IocContainer.GetContainer().Resolve<IPhoneService>() as PhoneService;

            _mapService = IocContainer.GetContainer().Resolve<IMapService>() as MapService;

            _emailService = IocContainer.GetContainer().Resolve<IEmailService>() as EmailService;

            _twitterHelper = IocContainer.GetContainer().Resolve<ITwitterHelper>() as AndroidTwitterHelper;

            _facebookHelper = IocContainer.GetContainer().Resolve<IFacebookHelper>() as AndroidFacebookHelper;
        }
Ejemplo n.º 34
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Phone" /> class.
        /// </summary>
        /// <param name="majorVersion">Major version.</param>
        /// <param name="minorVersion">Minor version.</param>
        public Phone(int majorVersion, int minorVersion)
        {
            PhoneService = new PhoneService();

            switch (majorVersion)
            {
                case 1:
                    Version = minorVersion == 1 ? PhoneType.IPhone1G : PhoneType.IPhone3G;
                    break;
                case 2:
                    Version = PhoneType.IPhone3Gs;
                    break;
                case 3:
                    Version = minorVersion == 1 ? PhoneType.IPhone4Gsm : PhoneType.IPhone4Cdma;
                    break;
                case 4:
                    Version = PhoneType.IPhone4S;
                    break;
                case 5:
                    Version = PhoneType.IPhone5Gsm + minorVersion - 1;
                    break;
                case 6:
                    Version = minorVersion == 1 ? PhoneType.IPhone5SCdma : PhoneType.IPhone5SGsm;
                    break;
                case 7:
                    Version = minorVersion == 1 ? PhoneType.IPhone6Plus : PhoneType.IPhone6;
                    break;
                case 8:
                    Version = minorVersion == 1 ? PhoneType.IPhone6S : PhoneType.IPhone6SPlus;
                    break;
                default:
                    Version = PhoneType.Unknown;
                    break;
            }

            switch (Version)
            {
                case PhoneType.IPhone6:
                case PhoneType.IPhone6S:
                    Display = new Display(1334, 750, 326, 326);
                    break;
                case PhoneType.IPhone6Plus:
                case PhoneType.IPhone6SPlus:
                    Display = new Display(2208, 1242, 401 * 1242 / 1080, 401 * 2208 / 1920);
                    break;
                default:
                    if (majorVersion > 4)
                    {
                        Display = new Display(1136, 640, 326, 326);
                    }
                    else if (majorVersion > 2)
                    {
                        Display = new Display(960, 640, 326, 326);
                    }
                    else
                    {
                        Display = new Display(480, 320, 163, 163);
                    }
                    break;
            }

            Name = HardwareVersion = Version.GetDescription();
        }