예제 #1
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (newInstance)
            {
                if (viewModel == null)
                {
                    if (State.Count > 0)
                    {
                        viewModel = (EditDescriptionViewModel)State["viewModel"];
                    }
                    else
                    {
                        if (IsolatedStorageSettings.ApplicationSettings.Contains("situation"))
                        {
                            if (IsolatedStorageSettings.ApplicationSettings["situation"].Equals(true))
                            {
                                viewModel = new EditDescriptionViewModel(selectedItemDataChargeDestination2.person,
                                                                         selectedItemDataChargeDestination2.description);
                            }
                            else
                            {
                                viewModel = new EditDescriptionViewModel(selectedItemDataLoanDestination2.person,
                                                                         selectedItemDataLoanDestination2.description);
                            }
                        }
                    }
                }
                this.DataContext = viewModel;
            }

            newInstance = false;
        }
        public async Task SaveCommandCallsDescriptionActionAndPassesItsNewDescription()
        {
            // Arrange
            bool   called         = false;
            string description    = "";
            string newDescription = "NEW DESCRIPTION";

            void SaveAction(string s)
            {
                called      = true;
                description = s;
            }

            SetDescriptionAction     += SaveAction;
            _editDescriptionViewModel = new EditDescriptionViewModel(_navigation, new EditDescriptionInfo(_title, _description, SetDescriptionAction, false));

            // Act
            _editDescriptionViewModel.Description = newDescription;
            await _editDescriptionViewModel.SaveCommand.ExecuteAsync(null);

            SetDescriptionAction -= SaveAction;

            // Assert
            Assert.IsTrue(called);
            Assert.AreEqual(description, newDescription);
        }
 public void TestInit()
 {
     _navigation               = Mock.Create <INavigationService>();
     _title                    = "TITLE";
     _description              = "DESCRIPTION";
     SetDescriptionAction      = d => _description = d;
     _editDescriptionViewModel = new EditDescriptionViewModel(_navigation, new EditDescriptionInfo(_title, _description, SetDescriptionAction, false));
 }
예제 #4
0
        /// <summary>
        /// Calls to API to Edit Desciription
        /// </summary>
        /// <param name="model"></param>
        private void EditDescriptionCall(EditDescriptionViewModel model)
        {
            var request = new RestRequest("TimelineEvent/EditDescription");

            if (!PutRequest(request, model).Equals("OK")) //Error Handling
            {
                throw new System.ArgumentException("Parameter cannot be null", "original");
            }
        }
        public async Task <ActionResult> DescriptionEditPost(string id, [Bind("Id,Description")] EditDescriptionViewModel vm)
        {
            if (ModelState.IsValid)
            {
                TimelineEvent @event = _repo.GetTimelineEvent(id);
                @event.Description = vm.Description;
                await _repo.EditDescriptionAsync(@event);

                return(PartialView("Description", @event));
            }

            return(PartialView("DescriptionEdit", vm));
        }
예제 #6
0
 public IActionResult EditDescription(EditDescriptionViewModel model)
 {
     try                             //ErrorHandling
     {
         EditDescriptionCall(model); //Calls to Edit
     }
     catch
     {
         return(RedirectToAction("APIError"));
     }
     _toastNotification.AddInfoToastMessage("The event description has been edited!");
     return(RedirectToAction("TimelineView", new { id = GetTimelineID(model.TimelineEventId) })); //returns to the Index!
 }
예제 #7
0
        public ActionResult Description(int id)
        {
            DescriptionDTO description        = _descriptionService.GetDescriptionByIdRealEstate(id);
            var            photoForGalleryDto = _descriptionService.GetPhotoForGalleryById(id).ToList();
            var            model = new EditDescriptionViewModel()
            {
                RealEstateId     = description.RealEstateId,
                ShortDescription = description.ShortDescription,
                LongDescription  = description.LongDescription,
                PhotosDto        = photoForGalleryDto
            };

            ViewBag.Id = id;
            return(View(model));
        }
예제 #8
0
        public ActionResult Description(EditDescriptionViewModel model)
        {
            if (ModelState.IsValid)
            {
                DescriptionDTO description    = _descriptionService.GetDescriptionByIdRealEstate(model.RealEstateId);
                var            descriptionDto = new DescriptionDTO()
                {
                    Id               = model.Id,
                    RealEstateId     = description.RealEstateId,
                    ShortDescription = model.ShortDescription,
                    LongDescription  = model.LongDescription
                };
                _descriptionService.UpdateDescriptionDto(descriptionDto);
                _descriptionService.Save();
                return(RedirectToAction("Particulars", "Home", new { id = descriptionDto.RealEstateId }));
            }

            return(View(model));
        }
        public async Task DiscardCommandWontCallSaveIfTheAlertResponseIsNegative()
        {
            // Arrange
            bool called = false;

            void SaveActionWhichShouldntBeCalled(string str)
            {
                called = true;
            }

            Mock.Arrange(() => _navigation.DisplayAlert(Arg.AnyString, Arg.AnyString, Arg.AnyString, Arg.AnyString)).Returns(Task.FromResult(false));
            _editDescriptionViewModel = new EditDescriptionViewModel(_navigation, new EditDescriptionInfo(_title, _description, SaveActionWhichShouldntBeCalled, false));

            // Act
            await _editDescriptionViewModel.DiscardCommand.ExecuteAsync(null);

            // Assert
            Assert.IsFalse(called);
        }
예제 #10
0
        public ActionResult EditDescription(EditDescriptionViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Clan updateClan = ClanManager.SelectByClanId(model.ClanId);

                    updateClan.description = model.Description;

                    ClanManager.Update(updateClan);
                }
            }
            catch
            {
                return(View());
            }

            return(RedirectToAction("Index"));
        }
 public EditDescriptionPage(EditDescriptionInfo info)
 {
     ViewModel = new EditDescriptionViewModel(((App)Application.Current).Navigation, info);
     InitializeComponent();
 }
예제 #12
0
        public PartialViewResult EditDescription(string Id, string Description)
        {
            EditDescriptionViewModel model = new EditDescriptionViewModel(Id, Description);

            return(PartialView("_EditDescription", model));
        }