public async Task <IActionResult> Edit(int id, [Bind("ID,Department,Number")] PhoneNumberModel phoneNumberModel)
        {
            if (id != phoneNumberModel.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    phoneNumberModel.Name = null;
                    _context.Update(phoneNumberModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PhoneNumberModelExists(phoneNumberModel.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(phoneNumberModel));
        }
 //  Create model from entity.
 public CompanyModel(Company entity)
 {
     Name        = entity.Name;
     Address     = new AddressModel(entity.Address);
     PhoneNumber = new PhoneNumberModel(entity.PhoneNumber);
     Website     = new WebsiteModel(entity.Website);
 }
        public async Task <IActionResult> PostPhoneNumberModel([FromBody] PhoneNumberModel phoneNumberModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.PhoneNumber.Add(phoneNumberModel);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (PhoneNumberModelExists(phoneNumberModel.ID))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetPhoneNumberModel", new { id = phoneNumberModel.ID }, phoneNumberModel));
        }
Beispiel #4
0
        public async Task <IActionResult> saveUserPhoneNumber([FromBody] PhoneNumberModel phoneNumberModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    UInt64 number;

                    if (!UInt64.TryParse(phoneNumberModel.PhoneNumber, System.Globalization.NumberStyles.AllowLeadingSign,
                                         CultureInfo.InvariantCulture, out number))
                    {
                        _logger.LogError($"Invalid value supplied as phone number: {phoneNumberModel.PhoneNumber}");
                        return(BadRequest($"Invalid value supplied as phone number."));
                    }
                    _logger.LogInformation($"Saving user {User.Identity.Name}'s phone number...............\n");
                    var user = await _userManager.FindByNameAsync(User.Identity.Name);

                    user.PhoneNumber = phoneNumberModel.PhoneNumber;
                    await _userManager.UpdateAsync(user);

                    _logger.LogInformation($"User {user.Email}'s phone number saved.......");
                    return(Ok($"Phone number saved......."));
                }
                _logger.LogError($"Invalid value supplied as phone number: {phoneNumberModel.PhoneNumber}.");
                return(BadRequest($"Invalid value supplied as phone number."));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Something went wrong in HomeController's saveUserPhoneNumber endpoint.");
                return(BadRequest());
            }
        }
        public async Task <IActionResult> PutPhoneNumberModel([FromRoute] int id, [FromBody] PhoneNumberModel phoneNumberModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != phoneNumberModel.ID)
            {
                return(BadRequest());
            }

            _context.Entry(phoneNumberModel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PhoneNumberModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(phoneNumberModel));
        }
Beispiel #6
0
        public ActionResult UpdatePhoneNumber(PhoneNumberModel phoneNumberModel)
        {
            if (ModelState.IsValid)
            {
                var result = _userManager.SetPhoneNumberAsync(phoneNumberModel.Id, phoneNumberModel.PhoneNumber).Result;
                if (result.Succeeded)
                {
                    return(RedirectToAction("UserInformation", new { userId = phoneNumberModel.Id }));
                }
            }

            var isChangeYourself = new Guid(User.Identity.GetIdUser()) == phoneNumberModel.Id;
            var isAircrewMember  = isChangeYourself && User.IsInRole("AircrewMember");

            if (isAircrewMember || _userManager.IsInRoleAsync(phoneNumberModel.Id, "AircrewMember").Result)
            {
                var modelAircrewMember = GetAircrewMemberModel(phoneNumberModel.Id);

                return(View("AircrewMemberInformation", modelAircrewMember));
            }

            var model = _userManager.FindByIdAsync(phoneNumberModel.Id).Result.ToDto();

            return(View("UserInformation", model));;
        }
Beispiel #7
0
        private void Choose_ReadyButtonClicked(object sender, EventArgs e)
        {
            ChoosePerson choose = (ChoosePerson)sender;

            PersonModel selectedPerson = choose.SelectedPersons.First();

            SelectedPerson      = selectedPerson;
            senderLabel.Content = selectedPerson.FullName;

            _parent.mainCanvas.Children.Remove(choose);

            AdditionalChoose addChoose = new AdditionalChoose(selectedPerson.PhoneNumbers.Cast <object>().ToList(), "Wybierz numer telefonu");

            addChoose.ReadyButtonClicked += (s2, ea2) =>
            {
                PhoneNumberModel selectedNumber = (PhoneNumberModel)addChoose.SelectedItems[0];
                SelectedPhoneNumber  = selectedNumber;
                senderLabel.Content += " (" + selectedNumber.Number + ")";
                _parent.mainCanvas.Children.Remove(addChoose);
                Darkened = false;
            };

            addChoose.CancelButtonClicked += (s2, ea2) =>
            {
                _parent.mainCanvas.Children.Remove(addChoose);
                Darkened            = false;
                senderLabel.Content = "";
            };

            _parent.mainCanvas.Children.Add(addChoose);
        }
Beispiel #8
0
        /// <summary>
        /// Parses a phone number into an intermediate representation in order
        /// to retrieve its country code, area code, participant number and
        /// extension
        /// </summary>
        /// <param name="input">Phone number to be parsed</param>
        /// <param name="parsedNumber">Intermediate representation of partial phone number codes</param>
        /// <returns>Returns a boolean value indicating if the input string is a valid phone number</returns>
        public bool ParsePhoneNumber(string input, out PhoneNumberModel parsedNumber)
        {
            PhoneNumberModel number = new PhoneNumberModel();

            if (input.StartsWith("00"))
            {
                input = "+" + input.Remove(0, 2);
            }

            input = Regex.Replace(input, @"[()\[\]/]", "");

            List <string> parts = input.Split('-').ToList();

            if (parts.Count > 1)
            {
                number.Extension = parts.Last();
                parts.RemoveAt(parts.Count - 1);
                input = string.Join("", parts);
            }

            PhoneNumber numberRepresentation = GetPhoneNumberRepresentation(input);

            if (phoneUtil.IsValidNumber(numberRepresentation))
            {
                GetPartialCodes(ref number, numberRepresentation);
                parsedNumber = number;
                return(true);
            }
            else
            {
                parsedNumber = null;
                return(false);
            }
        }
Beispiel #9
0
        public static PhoneNumberModel InputPhoneNumber()
        {
            PhoneNumberModel phoneModel = new PhoneNumberModel();

            phoneModel.Number    = StringInputSameLine("Phone number");
            phoneModel.PhoneType = InputPhoneType();
            return(phoneModel);
        }
Beispiel #10
0
        internal async Task UpdatePhoneNumber()
        {
            DeletePhoneNumberRequest deleteRequest = new DeletePhoneNumberRequest();

            Console.WriteLine();
            Console.WriteLine("Enter Phone Number ID: ");
            int numberID = UIHelper.EnterInteger();

            try
            {
                Console.WriteLine($"Looking up phone number with ID={numberID} on the server");
                PhoneNumberModel phoneNumber = await phoneBookClient.GetPhoneNumberAsync(new GetPhoneNumberRequest { NumberID = numberID });

                Console.WriteLine("Found phone number:");
                UIHelper.PrintPhoneNumberMultiline(phoneNumber);
                Console.Write("Are you sure you want to delete this phone number? (Y/N): ");
                var confirmation = Console.ReadKey();
                Console.WriteLine();
                if (confirmation.KeyChar == 'Y' || confirmation.KeyChar == 'y')
                {
                    try
                    {
                        var phoneNumberRequest = UIHelper.InputPhoneNumber();
                        phoneNumberRequest.NumberID = numberID;
                        var response = await phoneBookClient.UpdatePhoneNumberAsync(phoneNumberRequest);

                        Console.WriteLine();
                        Console.WriteLine($"Number is updated, this is contact details from the server: ");
                        UIHelper.PrintContact(response);
                    }
                    catch (RpcException rpcException)
                    {
                        Console.WriteLine("There was an error communicating with gRPC server");
                        Console.WriteLine($"Code: {rpcException.StatusCode}, Status: {rpcException.Status}");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex);
                    }
                }
            }
            catch (RpcException rpcException)
            {
                if (rpcException.StatusCode == StatusCode.NotFound)
                {
                    Console.WriteLine($"Could not find number with ID={numberID}");
                }
                else
                {
                    Console.WriteLine("There was an error communicating with gRPC server");
                    Console.WriteLine($"Code: {rpcException.StatusCode}, Status: {rpcException.Status}");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Beispiel #11
0
        public static IPhoneNumber MappFrom(PhoneNumberDTO phoneNumber)
        {
            PhoneNumberModel phoneNumberModel = new PhoneNumberModel();

            SetCommonDboProperties(phoneNumberModel, phoneNumber);
            phoneNumberModel.Value = phoneNumber.Value;
            phoneNumberModel.Type  = phoneNumber.Type;
            return(phoneNumberModel);
        }
        public ActionResult Create(string contactId)
        {
            var oid   = ControllerHelpers.GetObjectId(contactId);
            var model = new PhoneNumberModel {
                ContactId = oid,
            };

            return(View(model));
        }
Beispiel #13
0
 public PhoneNumber CreatePhoneNumber(PhoneNumberModel contactPhoneNumber, Contact contact)
 {
     return(new PhoneNumber()
     {
         ID = contactPhoneNumber.ID,
         Number = contactPhoneNumber.PhoneNumber,
         ContactID = contact != null ? contact.ID : 0,
         Contact = contact//contactPhoneNumber.ID > 0 ? contact : null
     });
 }
 public ActionResult Delete(PhoneNumberModel model)
 {
     try {
         phoneNumberService.RemoveContactPhoneNumber(model.ContactId, model.Id);
         return(RedirectToAction("Index", new { id = model.ContactId }));
     } catch (Exception ex) {
         ViewBag.ErrorMessage = ex.Message;
         return(View(model));
     }
 }
        public async Task <IActionResult> Create([Bind("ID,Department,Name,Number")] PhoneNumberModel phoneNumberModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(phoneNumberModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(phoneNumberModel));
        }
        public override Task <PhoneNumberModel> GetPhoneNumber(GetPhoneNumberRequest request, ServerCallContext context)
        {
            PhoneNumberModel phoneNumberResponse = repository.FindPhoneNumber(request.NumberID);

            if (phoneNumberResponse == null)
            {
                throw new RpcException(new Status(StatusCode.NotFound, $"Phone number with ID={request.NumberID} is not found."));
            }

            return(Task.FromResult(phoneNumberResponse));
        }
Beispiel #17
0
        public async Task <IActionResult> SendSmsAsync(PhoneNumberModel model)
        {
            var result = await _smsService.SendSmsAsync(model.InternationalPhoneNumber, model.CountryCode);

            if (result.IsFailure)
            {
                return(BadRequest(result.Errors));
            }

            return(Ok());
        }
Beispiel #18
0
        public async Task <ActionResult> Index(VoteForm voteForm)
        {
            if (_phoneNumberModelService.GetPhoneNumberModels().Where(phone => phone.PhoneNumber == voteForm.PhoneNumber).ToList().Count != 0)
            {
                ModelState.AddModelError("Телефонный номер", "Голос с использованием такого номера уже есть!");
            }
            if (voteForm.Place == null)
            {
                ModelState.AddModelError("Место для голосования", "Пожалуйста, выберите место для голосования.");
            }

            if (ModelState.IsValid)
            {
                TargetModel      target  = _targetModelService.GetTargetModel(Convert.ToInt32(voteForm.Target));
                VotePlaceModel   place   = _votePlaceModelService.GetVotePlaceModel(Convert.ToInt32(voteForm.Place));
                VoteProcessModel process = _voteProcessModelService.GetVoteProcessModels().ToList().Last();
                PhoneNumberModel phoneNumber;

                if (HttpContext.User.Identity.IsAuthenticated)
                {
                    ApplicationUser user = await _userManager.GetUserAsync(User);

                    phoneNumber = new PhoneNumberModel()
                    {
                        PhoneNumber = user.PhoneNumber
                    };
                }
                else
                {
                    phoneNumber = new PhoneNumberModel()
                    {
                        PhoneNumber = voteForm.PhoneNumber
                    };
                }

                _voteModelService.InsertVoteModel(
                    new VoteModel()
                {
                    CreatedAt     = DateTime.Now,
                    TargetId      = target,
                    VotePlaceId   = place,
                    PhoneNumberId = phoneNumber,
                    VoteProcessId = process
                });
                _logger.LogInformation($"{voteForm.PhoneNumber} voted");
                await _hubContext.Clients.All.SendAsync("Stat", "update");

                return(RedirectToAction(nameof(VoteSuccess)));
            }
            else
            {
                return(await Index());
            }
        }
Beispiel #19
0
        public void Configure(UINavigationController navigationController, PhoneNumberModel phoneNumberInfo)
        {
            _navigationController                         = navigationController;
            PhoneNumberInfoDatasourceChanged              = phoneNumberInfo.PhoneNumberDatasourceChangedCallEvent;
            phoneNumberInfo.PhoneNumberDatasourceChanged += PhoneNumberDatasourceChanged;
            NotifyChanges += phoneNumberInfo.NotifyChanges;

            if (PhoneNumberInfoDatasourceChanged != null)
            {
                PhoneNumberInfoDatasourceChanged();
            }
        }
Beispiel #20
0
        public async Task <OperationResult> AddPhoneAsync(PhoneNumberModel model)
        {
            var userDTO = mapper.Map <PhoneNumberModel, PhoneNumber>(model);

            if (await unitOfWork.PhoneNumberRepository.Exists(model.Number, model.UserID))
            {
                return(new OperationResult(false, "PhoneNumber exists!"));
            }
            await unitOfWork.PhoneNumberRepository.AddPhoneNumberAsync(userDTO);

            return(await unitOfWork.CompleteAsync());
        }
        public ActionResult Edit(PhoneNumberModel model)
        {
            if (ModelState.IsValid)
            {
                try {
                    phoneNumberService.UpdateContactPhoneNumber(model.ContactId, model.ToEntity());
                    return(RedirectToAction("Index", new { id = model.ContactId }));
                } catch (Exception ex) {
                    ViewBag.ErrorMessage = ex.Message;
                    return(View(model));
                }
            }

            return(View(model));
        }
        public OrderEditViewModel(IOrderWorkflowService orderWorkflowService, IAccountService accountService, IPaymentService paymentService, INetworkRoamingService networkRoamingService)
        {
            _orderWorkflowService  = orderWorkflowService;
            _accountService        = accountService;
            _paymentService        = paymentService;
            _networkRoamingService = networkRoamingService;

            _chargeTypes = new ListItem[0];

            Observe(_orderWorkflowService.GetAndObserveBookingSettings(), bookingSettings => BookingSettings = bookingSettings.Copy());
            Observe(_orderWorkflowService.GetAndObservePickupAddress(), address => PickupAddress             = address.Copy());
            Observe(_accountService.GetAndObservePaymentsList(), paymentTypes => PaymentTypesChanged(paymentTypes).FireAndForget());

            PhoneNumber = new PhoneNumberModel();
        }
Beispiel #23
0
        public static PhoneNumber ToDomain(this PhoneNumberModel model, PhoneNumber domain)
        {
            if (model != null)
            {
                domain.Id        = model.Id;
                domain.Number    = model.Number;
                domain.IsPrimary = model.IsPrimary;

                if (model.Type != null)
                {
                    domain.Type.Id = model.Type.Id;
                }
            }

            return(domain);
        }
        public async Task <IActionResult> GetPhoneNumberModel([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            PhoneNumberModel phoneNumberModel = await _context.PhoneNumber.SingleOrDefaultAsync(m => m.ID == id);

            if (phoneNumberModel == null)
            {
                return(NotFound());
            }

            return(Ok(phoneNumberModel));
        }
Beispiel #25
0
        private void _contactList_PersonShowDetails(object sender, EventArgs e)
        {
            ContactPersonListItem personItem = (ContactPersonListItem)sender;
            PersonDetails         details    = new PersonDetails(_parent, personItem.Person);

            details.ReadyButtonClicked += (s, ea) =>
            {
                List <PersonDetailListItem> emailItems = details.EmailItems;
                List <PersonDetailListItem> phoneItems = details.PhoneItems;

                foreach (PersonDetailListItem detail in emailItems)
                {
                    EmailAddressModel emailAdress = (EmailAddressModel)detail.ChildObject;
                    emailAdress.Name    = detail.Name;
                    emailAdress.Address = detail.DetailValue;
                    detail.ChildObject  = emailAdress;
                }

                foreach (PersonDetailListItem detail in phoneItems)
                {
                    PhoneNumberModel phoneNumber = (PhoneNumberModel)detail.ChildObject;
                    phoneNumber.Name   = detail.Name;
                    phoneNumber.Number = detail.DetailValue;
                    detail.ChildObject = phoneNumber;
                }

                _parent.Client.UpdatePersonDetails(details.Person.Id, details.FirstNameTextBox.Text,
                                                   details.LastNameTextBox.Text,
                                                   details.GenderComboBox.SelectedItem == details.GenderComboBox.Items.First()
                        ? Gender.Female
                        : Gender.Male, details.Company,
                                                   details.EmailItems.Select(obj => (EmailAddressModel)obj.ChildObject).ToList(),
                                                   details.PhoneItems.Select(obj => (PhoneNumberModel)obj.ChildObject).ToList());

                _parent.Darkened = false;
                _parent.mainCanvas.Children.Remove(details);
            };

            details.CancelButtonClicked += (s, ea) =>
            {
                _parent.Darkened = false;
                _parent.mainCanvas.Children.Remove(details);
            };

            _parent.Darkened = true;
            _parent.mainCanvas.Children.Add(details);
        }
        public override Task <ContactModel> UpdatePhoneNumber(PhoneNumberModel request, ServerCallContext context)
        {
            PhoneNumberModel updatePhone   = null;
            ContactModel     updateContact = null;

            repository.FindContactAndPhoneNumber(request.NumberID, out updateContact, out updatePhone);

            if (updatePhone == null || updateContact == null)
            {
                throw new RpcException(new Status(StatusCode.NotFound, $"Phone number with ID={request.NumberID} is not found."));
            }

            updatePhone.Number    = request.Number;
            updatePhone.PhoneType = request.PhoneType;

            return(Task.FromResult(updateContact));
        }
Beispiel #27
0
        public static PhoneNumber ToDomain(this PhoneNumberModel model)
        {
            var domain = new PhoneNumber();

            if (model != null)
            {
                domain.Id        = model.Id;
                domain.Number    = model.Number;
                domain.IsPrimary = model.IsPrimary;

                if (model.Type != null)
                {
                    domain.Type = model.Type.ToDomain();
                }
            }

            return(domain);
        }
Beispiel #28
0
        public static PhoneNumberModel ToModel(this PhoneNumber domain)
        {
            var model = new PhoneNumberModel();

            if (domain != null)
            {
                model.Id        = domain.Id;
                model.Number    = domain.Number;
                model.IsPrimary = domain.IsPrimary;

                if (domain.Type != null)
                {
                    model.Type = domain.Type.ToModel();
                }
            }

            return(model);
        }
Beispiel #29
0
        public void Test_0049201123456()
        {
            // Arrange
            var model = new PhoneNumberModel
            {
                AreaCode          = "201",
                CountryCode       = "49",
                Extension         = null,
                ISOCountryText    = "DE",
                ParticipantNumber = "123456"
            };

            // Act
            var success = phoneNumberParser.ParsePhoneNumber("0049201123456", out var number);

            // Assert
            Assert.IsTrue(success);
            Assert.AreEqual(model, number);
        }
Beispiel #30
0
        public void Test_Fail_plus440201123456()
        {
            // Arrange
            var model = new PhoneNumberModel
            {
                AreaCode          = "201",
                CountryCode       = "44",
                Extension         = null,
                ISOCountryText    = "GB",
                ParticipantNumber = "123456"
            };

            // Act
            var success = phoneNumberParser.ParsePhoneNumber("+44 0201123456", out var number);

            // Assert
            Assert.IsFalse(success);
            Assert.IsNull(number);
        }
 private PhoneNumber ConvertToDbo(PhoneNumberModel model)
 {
     return new PhoneNumber
     {
         Id = model.Id ?? 0,
         Number = model.Number
     };
 }
		/// <summary>
		/// Inisializez new instance of <see cref="PhoneNumbersControlViewModel"/> class.
		/// </summary>
		public PhoneNumbersControlViewModel()
		{
			_phoneNumberModel = new PhoneNumberModel();
			_phoneNumberModel.PropertyChanged+=PhoneNumberModelOnPropertyChanged;
		}