예제 #1
0
        /// <summary>
        /// Searches the specified text.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="cp">The cp.</param>
        /// <returns></returns>
        public ActionResult Search(string text, string cp)
        {
            List <Media> media       = (!string.IsNullOrEmpty(text) ? _mediaRepository.SearchByTextAndUserId(text, Owner.Id) : new List <Media>());
            string       encodedText = HttpUtility.HtmlEncode(text);

            IDictionary <string, string> crumbs = new Dictionary <string, string>
            {
                { "home", UrlService.UserRoot() },
                { "search", string.Empty },
                { string.Format("'{0}'", encodedText), UrlService.UserUrl(string.Format("search/ '{0}'", encodedText)) }
            };

            int    page   = (string.IsNullOrEmpty(cp) ? 1 : Convert.ToInt32(cp));
            string setKey = string.Empty;

            if (media.Count > 0)
            {
                setKey = _persistentCollectionService.Set(Authorization.Owner.Username + "_user_Search_" + encodedText, media, Persistence.Temporary);
                _persistentCollectionService.SetBackUrl(string.Format("{0}/search?text={1}&cp={2}", Authorization.Owner.Username, encodedText, page), SiteCookie);
            }

            UserSearchView view = ModelFactory <UserSearchView>(new { SearchText = encodedText, TotalResults = media.Count, Pagination = _paginationService, Set = setKey });

            view.Pagination.GeneratePaging(media, page, 20, "?cp={0}&text=" + encodedText);
            _sidebarView.PopulateView(view, Owner);

            return(View(view, crumbs));
        }
        public void Index_NotGivenAnObject_Ignore()
        {
            var view = new UserSearchView();

            var results = view.Index("not an a valid input");

            Assert.That(results, Is.Empty);
        }
        public void Index_GivenProfileObject_MapToUserSearchViewData()
        {
            var view = new UserSearchView();
            var profileObject = Make_ProfileObject();

            var result = (UserSearchViewData)view.Index(profileObject).First();

            Assert.That(result.Name, Is.EqualTo("John Doe"));
        }
        public void Index_MissingMetadata_Ignore()
        {
            var view = new UserSearchView();
            var wrongObjectType = new Object{ObjectTypeID = 55};

            var results = view.Index(wrongObjectType);

            Assert.That(results, Is.Empty);
        }
        public void Index_GivenWrongObjectType_Ignore()
        {
            var view = new UserSearchView();
            var wrongObjectType = new Object();

            var results = view.Index(wrongObjectType);

            Assert.That(results, Is.Empty);
        }
예제 #6
0
        void MailToUser()
        {
            User receivingUser = null;
            var  usv           = new UserSearchView();

            if (usv.ShowDialog() == DialogResult.OK && usv.SelectedUser != null)
            {
                receivingUser = usv.SelectedUser;
                var pdfFile     = PdfManager.PdfService.CreateOfferDocument(this.myOffer, true);
                var sendingUser = ModelManager.UserService.CurrentUser;
                var subject     = string.Format("Bestellung für {0} (gesendet von {1})", this.myOffer.Customer.CompanyName1, sendingUser.NameFull);
                var body        = string.Format("Moin {0}. Kannst Du Dich bitte um die Bestellung für {1} im Anhang kümmern? \n\nBesten Dank\n{2}",
                                                receivingUser.NameFirst,
                                                this.myOffer.Customer.CompanyName1,
                                                sendingUser.NameFirst);
                ModelManager.PostBuedel.SendEmail(receivingUser.EmailWork, subject, body, pdfFile, new List <string> {
                    sendingUser.EmailWork
                });

                var msg = string.Format("Die Bestellung für {0} wurde an {1} gesendet", this.myOffer.Customer.CompanyName1, receivingUser.NameFull);
                MetroMessageBox.Show(this, msg, "Catalist", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.myOffer.SetPrintDateOrder();
            }
        }