Exemplo n.º 1
0
        public async Task <IActionResult> ShortUrl2Async(long id, string theme,
                                                         CancellationToken token)
        {
            _userManager.TryGetLongUserId(User, out var userId);
            var query = new DocumentById(id, userId);
            var model = await _queryBus.QueryAsync(query, token);

            if (model == null)
            {
                return(NotFound());
            }
            var t = RedirectToRoutePermanent(SeoTypeString.Document, new
            {
                courseName = FriendlyUrlHelper.GetFriendlyTitle(model.Document.Course),
                id,
                theme,
                name = FriendlyUrlHelper.GetFriendlyTitle(model.Document.Title)
            });

            return(t);
        }
Exemplo n.º 2
0
        public IViewComponentResult Invoke()
        {
            var model         = new TopMenuModel();
            var result        = new List <CategorySimpleModel>();
            var allCategories = _categoryService.GetAllCategories();

            foreach (var category in allCategories)
            {
                var categoryModel = new CategorySimpleModel
                {
                    Id               = category.Id,
                    Name             = category.Name,
                    SeName           = FriendlyUrlHelper.GetFriendlyTitle(_urlRecordService.GetSeName(category), true),
                    IncludeInTopMenu = category.IncludeInTopMenu,
                    ParentCategoryId = category.ParentCategoryId
                };
                result.Add(categoryModel);
            }
            model.Categories = result;
            return(View(model));
        }
        public async Task <Post> CreatePostAsync(Post model)
        {
            string CoverImagePath;

            if (Constants.Blog.UseBlobStorage == "y")
            {
                string uniqueFileName = Guid.NewGuid().ToString() + "_" + model.CoverImage.FileName;
                await _blobService.UploadFileBlobAsync(Constants.Blog.BlobContainerNameFeaturedImage, model.CoverImage.OpenReadStream(), model.CoverImage.ContentType, uniqueFileName);

                CoverImagePath = $"/{Constants.Blog.BlobContainerNameFeaturedImage}/{uniqueFileName}";
            }
            else
            {
                CoverImagePath = await UploadedFile(model);
            }

            string friendlyTitle = FriendlyUrlHelper.GetFriendlyTitle(model.Title);

            await SaveFilesToDisk(model).ConfigureAwait(false);

            Post post = new Post
            {
                Title          = model.Title,
                Excerpt        = model.Excerpt,
                Content        = model.Content,
                IsPublished    = model.IsPublished,
                Tags           = model.Tags,
                CoverImagePath = CoverImagePath,
                PubDate        = DateTime.Now,
                Slug           = friendlyTitle
            };

            await _context.Posts.AddAsync(post);

            await _context.SaveChangesAsync();

            return(post);
        }
Exemplo n.º 4
0
        public async Task <IActionResult> GetProduct(int id, string ProductName)
        {
            var sessionToken = HttpContext.Session.GetString("Token");
            var refreshToken = HttpContext.Session.GetString("RefreshToken");

            if (sessionToken == null)
            {
                await HttpContext.SignOutAsync();

                HttpContext.Session.Clear();
                return(RedirectToAction("Index", "Home"));
            }

            var httpResponse = await _medByteApiService.GetProuct(id, sessionToken, refreshToken, async token => {
                HttpContext.Session.SetString("Token", token);
                sessionToken = token;
            });

            if (httpResponse.IsSuccessStatusCode)
            {
                var content = await httpResponse.Content.ReadAsStringAsync();

                ProductViewModel product = JsonConvert.DeserializeObject <ProductViewModel>(content);
                if (product == null)
                {
                    return(this.NotFound());
                }
                string friendlyTitle = FriendlyUrlHelper.GetFriendlyTitle(product.ProductName);

                if (!string.Equals(friendlyTitle, ProductName, StringComparison.Ordinal))
                {
                    return(this.RedirectToRoutePermanent("GetProduct", new { id, title = friendlyTitle }));
                }
                return(View("Product", product));
            }
            return(View());
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Event(int id, string name)
        {
            string friendlyTitle = FriendlyUrlHelper.GetFriendlyTitle(name);

            if (!string.Equals(friendlyTitle, name, StringComparison.Ordinal))
            {
                return(RedirectToRoute("event", new { id = id, name = friendlyTitle }));
            }

            var model = new EventViewModel();

            model.SimilarEvents = await _publicEventService.GetSimilarEvents(id);

            if (User.Identity.IsAuthenticated)
            {
                model.PublicEvent = await _publicEventService.GetPublicEvent(id, User.FindFirstValue(ClaimTypes.NameIdentifier));
            }
            else
            {
                model.PublicEvent = await _publicEventService.GetPublicEvent(id);
            }

            return(View(model));
        }
        public async Task <CategoriesReponseModel> UpdateAsync(int id, UpdateCategoriesRequestModel updateCategoriesRequestModel)
        {
            const string actionName = nameof(UpdateAsync);

            updateCategoriesRequestModel = updateCategoriesRequestModel ?? throw new ArgumentNullException(nameof(updateCategoriesRequestModel));

            if (id != updateCategoriesRequestModel.Id)
            {
                throw new InconsistentException(nameof(updateCategoriesRequestModel));
            }

            var seoTitle = FriendlyUrlHelper.GetFriendlyTitle(updateCategoriesRequestModel.Name);

            Logger.LogInfomation(LoggingMessage.ProcessingRequestWithModel, actionName, seviceName, updateCategoriesRequestModel);

            var category = await _categoryRepository.GetAsync(id);

            if (category == null)
            {
                throw new NotFoundException(nameof(id));
            }

            category.Name     = updateCategoriesRequestModel.Name;
            category.Status   = updateCategoriesRequestModel.Status;
            category.SeoTitle = seoTitle;
            category.ParentId = updateCategoriesRequestModel.ParentId;

            //if (updateCategoriesRequestModel.Status != Enums.Status.Active && updateCategoriesRequestModel.Status != Enums.Status.InActive)
            //    throw new NotFoundException(nameof(updateCategoriesRequestModel));

            var response = await _categoryRepository.UpdateAsync(category, true);

            Logger.LogInfomation(LoggingMessage.ActionSuccessfully, actionName, seviceName, response);

            return(_Mapper.Map <CategoriesReponseModel>(response));
        }
Exemplo n.º 7
0
        public static IEnumerable <Book> Data()
        {
            var books = new List <Book>
            {
                // Caterogy 1
                new Book
                {
                    Id             = 1,
                    Name           = "Outliers: The Story of Success",
                    Slug           = FriendlyUrlHelper.GetFriendlyTitle("Outliers: The Story of Success", true),
                    Language       = "English",
                    ISBN           = "0316017930",
                    ISBN13         = "9780316017930",
                    Length         = 336,
                    Weight         = "0.75 lbs",
                    Author         = "Malcolm Gladwell",
                    Available2Lend = true,
                    Description    = "In this stunning new book, Malcolm Gladwell takes us on an intellectual journey through the world of outliers--the best and the brightest, the most famous and the most successful. He asks the question: what makes high-achievers different? His answer is that we pay too much attention to what successful people are like, and too little attention to where they are from: that is, their culture, their family, their generation, and the idiosyncratic experiences of their upbringing. Along the way he explains the secrets of software billionaires, what it takes to be a great soccer player, why Asians are good at math, and what made the Beatles the greatest rock band. Brilliant and entertaining, Outliers is a landmark work that will simultaneously delight and illuminate.",
                    Dimensions     = "8.3 x 1.1 x 5.5 (inches)",
                    ImageUrl       = "https://images-na.ssl-images-amazon.com/images/I/41LO6QRvIuL._SL300_.jpg",
                    PublishedDate  = new DateTime(2011, 6, 1),
                    BookCategoryId = 1
                },
                new Book
                {
                    Id             = 2,
                    Name           = "Life of Pi",
                    Slug           = FriendlyUrlHelper.GetFriendlyTitle("Life of Pi", true),
                    Language       = "English",
                    ISBN           = "0156027321",
                    ISBN13         = "N/A",
                    Length         = 326,
                    Weight         = "0.87 lbs",
                    Author         = "Yann Martel",
                    Available2Lend = true,
                    Description    = "No Synopsis Available.",
                    Dimensions     = "0.9 x 5.0 x 8.0 (inches)",
                    ImageUrl       = "https://images-na.ssl-images-amazon.com/images/I/51rxEvLljUL._SL300_.jpg",
                    PublishedDate  = new DateTime(2003, 5, 1),
                    BookCategoryId = 1
                },
                new Book
                {
                    Id             = 3,
                    Name           = "Think and Grow Rich: The Landmark Bestseller Now Revised and Updated for the 21st Century (Think and Grow Rich Series)",
                    Slug           = FriendlyUrlHelper.GetFriendlyTitle("Think and Grow Rich: The Landmark Bestseller Now Revised and Updated for the 21st Century (Think and Grow Rich Series)", true),
                    Language       = "English",
                    ISBN           = "1585424331",
                    ISBN13         = "9781585424337",
                    Length         = 320,
                    Weight         = "0.63 lbs.",
                    Author         = "Ben Holden-Crowther and Napoleon Hill",
                    Available2Lend = true,
                    Description    = "Please note that this item is a roughcut (deckle edge) editionThink and Grow Rich has been called the Granddaddy of All Motivational Literature. It was the first book to boldly ask, What makes a winner? The man who asked and listened for the answer, Napoleon Hill, is now counted in the top ranks of the world's winners himself. The most famous of all teachers of success spent a fortune and the better part of a lifetime of effort to produce the Law of Success philosophy that forms the basis of his books and that is so powerfully summarized in this one. In the original Think and Grow Rich, published in 1937, Hill draws on stories of Andrew Carnegie, Thomas Edison, Henry Ford, and other millionaires of his generation to illustrate his principles. In the updated version, Arthur R. Pell, Ph.D., a nationally known author, lecturer, and consultant in human resources management and an expert in applying Hill's thought, deftly interweaves anecdotes of how contemporary millionaires and billionaires, such as Bill Gates, Mary Kay Ash, Dave Thomas, and Sir John Templeton, achieved their wealth. Outmoded or arcane terminology and examples are faithfully refreshed to preclude any stumbling blocks to a new generation of readers.",
                    Dimensions     = "7.1 x 0.8 x 5.0 (inches)",
                    ImageUrl       = "https://images-na.ssl-images-amazon.com/images/I/61y04z8SKEL._SL300_.jpg",
                    PublishedDate  = new DateTime(2005, 8, 1),
                    BookCategoryId = 1
                },
                new Book
                {
                    Id             = 4,
                    Name           = "The Richest Man in Babylon",
                    Slug           = FriendlyUrlHelper.GetFriendlyTitle("The Richest Man in Babylon", true),
                    Language       = "English",
                    ISBN           = "1508524351",
                    ISBN13         = "9781508524359",
                    Length         = 100,
                    Weight         = "0.40 lbs",
                    Author         = "George S. Clason",
                    Available2Lend = true,
                    Description    = "This is the complete, original 1926 edition of a classic. (A condensed, simplified retelling is also available under the title The Richest Man in Babylon: Six Laws of Wealth , ISBN 1490348557.) As a young man, I came across George Samuel Clason's classic book The Richest Man in Babylon , which offered commonsense financial advice told through ancient parables. I recommend it to everyone. --Tony Robbins, Money: Master the Game The ancient Babylonians were the first people to discover the universal laws of prosperity. In his classic bestseller, The Richest Man in Babylon, George S. Clason reveals their secrets for creating, growing, and preserving wealth. Through these entertaining tales of merchants, tradesmen, and herdsmen, you'll learn how to keep more out what you earn; get out of debt; put your money to work; attract good luck; choose wise investments; and safeguard a lasting fortune.Visit SuccessBooks.net for more of the greatest success guides ever written.",
                    Dimensions     = "0.3 x 6.0 x 9.0 (inches)",
                    ImageUrl       = "https://img.thriftbooks.com/api/images/l/685fe07eae86303190e84e64ca377eac1b8f5919.jpg",
                    PublishedDate  = new DateTime(2015, 2, 1),
                    BookCategoryId = 1
                },
                // Category 2
                new Book
                {
                    Id             = 5,
                    Name           = "The 7 Habits of Highly Effective People : Powerful Lessons in Personal Change",
                    Slug           = FriendlyUrlHelper.GetFriendlyTitle("The 7 Habits of Highly Effective People : Powerful Lessons in Personal Change", true),
                    Language       = "English",
                    ISBN           = "1451639619",
                    ISBN13         = "9781451639612",
                    Length         = 432,
                    Weight         = "0.84 lbs",
                    Author         = "Stephen R. Covey",
                    Available2Lend = true,
                    Description    = "Millions of copies sold. New York Times Bestseller. Named the #1 Most Influential Business Book of the Twentieth Century. As the seminal work of Stephen R. Covey, The 7 Habits of Highly Effective People has influenced millions around the world to be their best selves at work and at home. It stands the test of time as one of the most important books of our time. --Indra Nooyi, CEO of PepsiCo One of the most inspiring and impactful books ever written, The 7 Habits of Highly Effective People has captivated readers for 25 years. It has transformed the lives of presidents and CEOs, educators and parents--in short, millions of people of all ages and occupations across the world. This twenty-fifth anniversary edition of Stephen Covey's cherished classic commemorates his timeless wisdom, and encourages us to live a life of great and enduring purpose.",
                    Dimensions     = "1.0 x 5.5 x 8.4 (inches)",
                    ImageUrl       = "https://img.thriftbooks.com/api/images/l/51e028cf7a5b685ff978e7e2f634fa924cfc5a25.jpg",
                    PublishedDate  = new DateTime(2013, 11, 1),
                    BookCategoryId = 1
                },
                new Book
                {
                    Id             = 6,
                    Name           = "The Millionaire Next Door : The Surprising Secrets of America's Wealthy",
                    Slug           = FriendlyUrlHelper.GetFriendlyTitle("The Millionaire Next Door : The Surprising Secrets of America's Wealthy", true),
                    Language       = "English",
                    ISBN           = "1589795474",
                    ISBN13         = "9781589795471",
                    Length         = 272,
                    Weight         = "0.68 lbs.",
                    Author         = "Thomas J. Stanley and William D. Danko",
                    Available2Lend = true,
                    Description    = "Why aren't I as wealthy as I should be? Many people ask this question of themselves all the time. Often they are hard-working, well educated middle- to high-income people. Why, then, are so few affluent. For nearly two decades the answer has been found in the bestselling The Millionaire Next Door: The Surprising Secrets of America's Wealthy, reissued with a new foreword for the twenty-first century by Dr.Thomas J.Stanley.According to the authors, most people have it all wrong about how you become wealthy in America.Wealth in America is more often the result of hard work, diligent savings, and living below your means than it is about inheritance, advance degrees, and even intelligence.The Millionaire Next Door identifies seven common traits that show up again and again among those who have accumulated wealth.You will learn, for example, that millionaires bargain shop for used cars, pay a tiny fraction of their wealth in income tax, raise children who are often unaware of their family's wealth until they are adults, and, above all, reject the big-spending lifestyles most of us associate with rich people. In fact, you will learn that the flashy millionaires glamorized in the media represent only a tiny minority of America's rich.Most of the truly wealthy in this country don't live in Beverly Hills or on Park Avenue-they live next door.",
                    Dimensions     = "0.8 x 5.9 x 9.1 (inches)",
                    ImageUrl       = "https://img.thriftbooks.com/api/images/l/258268f1c457bfdc20dcc186f0f470062551877b.jpg",
                    PublishedDate  = new DateTime(2010, 11, 1),
                    BookCategoryId = 2
                },
                new Book
                {
                    Id             = 7,
                    Name           = "The 21 Irrefutable Laws of Leadership : Follow Them and People Will Follow You",
                    Slug           = FriendlyUrlHelper.GetFriendlyTitle("The 21 Irrefutable Laws of Leadership : Follow Them and People Will Follow You", true),
                    Language       = "English",
                    ISBN           = "0785288376",
                    ISBN13         = "9780785288374",
                    Length         = 336,
                    Weight         = "1.19 lbs.",
                    Author         = "John C. Maxwell",
                    Available2Lend = true,
                    Description    = "If you've never read The 21 Irrefutable Laws of Leadership , you've been missing out on one of the best-selling leadership books of all time. If you have read the original version, then you'll love this new expanded and updated one. Internationally recognized leadership expert, speaker, and author John C. Maxwell has taken this million-seller and made it even better: Every Law of Leadership has been sharpened and updated Seventeen new leadership stories are included Two new Laws of Leadership are introduced New evaluation tool will reveal your leadership strengths--and weaknesses New application exercises in every chapter will help you grow Why would Dr. Maxwell make changes to his best-selling book? A book is a conversation between the author and reader, says Maxwell. It's been ten years since I wrote The 21 Laws of Leadership . I've grown a lot since then. I've taught these laws in dozens of countries around the world. This new edition gives me the opportunity to share what I've learned.",
                    Dimensions     = "1.1 x 6.4 x 9.3 (inches)",
                    ImageUrl       = "https://img.thriftbooks.com/api/images/l/15f48f64ed3486632e3f6cda5fa64890a65ca9b9.jpg",
                    PublishedDate  = new DateTime(2007, 9, 1),
                    BookCategoryId = 2
                },
                new Book
                {
                    Id             = 8,
                    Name           = "Rich Dad Poor Dad : What the Rich Teach Their Kids about Money That the Poor and Middle Class Do Not!",
                    Slug           = FriendlyUrlHelper.GetFriendlyTitle("Rich Dad Poor Dad : What the Rich Teach Their Kids about Money That the Poor and Middle Class Do Not!", true),
                    Language       = "English",
                    ISBN           = "1612680194",
                    ISBN13         = "9781612680194",
                    Length         = 336,
                    Weight         = "0.56 lbs.",
                    Author         = "Robert T. Kiyosaki",
                    Available2Lend = true,
                    Description    = "April 2017 marks 20 years since Robert Kiyosaki's Rich Dad Poor Dad first made waves in the Personal Finance arena. It has since become the #1 Personal Finance book of all time... translated into dozens of languages and sold around the world. Rich Dad Poor Dad is Robert's story of growing up with two dads -- his real father and the father of his best friend, his rich dad -- and the ways in which both men shaped his thoughts about money and investing. The book explodes the myth that you need to earn a high income to be rich and explains the difference between working for money and having your money work for you. 20 Years... 20/20 Hindsight In the 20th Anniversary Edition of this classic, Robert offers an update on what we've seen over the past 20 years related to money, investing, and the global economy. Sidebars throughout the book will take readers  fast forward  -- from 1997 to today -- as Robert assesses how the principles taught by his rich dad have stood the test of time. In many ways, the messages of Rich Dad Poor Dad , messages that were criticized and challenged two decades ago, are more meaningful, relevant and important today than they were 20 years ago. As always, readers can expect that Robert will be candid, insightful... and continue to rock more than a few boats in his retrospective. Will there be a few surprises? Count on it. Rich Dad Poor Dad ... - Explodes the myth that you need to earn a high income to become rich - Challenges the belief that your house is an asset - Shows parents why they can't rely on the school system to teach their kids about money - Defines once and for all an asset and a liability - Teaches you what to teach your kids about money for their future financial success",
                    Dimensions     = "1.1 x 4.3 x 7.5 (inches)",
                    ImageUrl       = "https://img.thriftbooks.com/api/images/l/7da997e4bfef47f6429c9d59556a4dd96af2d61e.jpg",
                    PublishedDate  = new DateTime(2017, 4, 1),
                    BookCategoryId = 2
                },
                new Book
                {
                    Id             = 9,
                    Name           = "La oruga muy hambrienta/The Very Hungry Caterpillar: bilingual board book [Spanish]",
                    Slug           = FriendlyUrlHelper.GetFriendlyTitle("La oruga muy hambrienta/The Very Hungry Caterpillar: bilingual board book [Spanish]", true),
                    Language       = "Spanish",
                    ISBN           = "0399256059",
                    ISBN13         = "9780399256059",
                    Length         = 24,
                    Weight         = "0.40 lbs.",
                    Author         = "Eric Carle",
                    Available2Lend = true,
                    Description    = "The time-honored classic The Very Hungry Caterpillar is now available in two bilingual formats, bringing together two languages for the ultimate reading and learning experience. With easily readable side-by-side English and Spanish text, it's perfect for children learning to speak either language. La oruga muy hambrienta es un libro lleno de colorido que habla de c?mo una oruga se transforma en una linda mariposa. Los ni?os se divierten al descrubrir los cambios tan asombrosos por los que pasa la oruga.",
                    Dimensions     = "7.1 x 0.7 x 5.0 (inches)",
                    ImageUrl       = "https://images-na.ssl-images-amazon.com/images/I/41OaVJC8efL._SL300_.jpg",
                    PublishedDate  = new DateTime(2011, 5, 1),
                    BookCategoryId = 2
                },
                new Book
                {
                    Id             = 10,
                    Name           = "Blink : The Power of Thinking Without Thinking",
                    Slug           = FriendlyUrlHelper.GetFriendlyTitle("Blink : The Power of Thinking Without Thinking", true),
                    Language       = "English",
                    ISBN           = "0316010669",
                    ISBN13         = "9780316010665",
                    Length         = 320,
                    Weight         = "0.72 lbs",
                    Author         = "Malcolm Gladwell and 麥爾坎·葛拉威爾",
                    Available2Lend = true,
                    Description    = "In his landmark bestseller The Tipping Point, Malcolm Gladwell redefined how we understand the world around us. Now, in Blink, he revolutionizes the way we understand the world within. Blink is a book about how we think without thinking, about choices that seem to be made in an instant-in the blink of an eye-that actually aren't as simple as they seem. Why are some people brilliant decision makers, while others are consistently inept? Why do some people follow their instincts and win, while others end up stumbling into error? How do our brains really work-in the office, in the classroom, in the kitchen, and in the bedroom? And why are the best decisions often those that are impossible to explain to others?In Blink we meet the psychologist who has learned to predict whether a marriage will last, based on a few minutes of observing a couple; the tennis coach who knows when a player will double-fault before the racket even makes contact with the ball; the antiquities experts who recognize a fake at a glance. Here, too, are great failures of blink: the election of Warren Harding; New Coke; and the shooting of Amadou Diallo by police. Blink reveals that great decision makers aren't those who process the most information or spend the most time deliberating, but those who have perfected the art of thin-slicing-filtering the very few factors that matter from an overwhelming number of variables.",
                    Dimensions     = "0.9 x 5.5 x 8.3 (inches)",
                    ImageUrl       = "https://img.thriftbooks.com/api/images/l/b67cd4ea2eb90f1b3553f5df371db4fe36935b03.jpg",
                    PublishedDate  = new DateTime(2007, 4, 1),
                    BookCategoryId = 2
                },

                // Category 2

                //new Book
                //{
                //    Id = 4,
                //    Name = "",
                //    Language ="English",
                //    ISBN = "",
                //    ISBN13 = "",
                //    Length = 0,
                //    Weight ="",
                //    Author ="",
                //    Available2Lend = true,
                //    Description = "",
                //    Dimensions ="",
                //    ImageUrl ="",
                //    PublishedDate = new DateTime(1,1,1)
                //},
                //new Book
                //{
                //    Id = 4,
                //    Name = "",
                //    Language ="English",
                //    ISBN = "",
                //    ISBN13 = "",
                //    Length = 0,
                //    Weight ="",
                //    Author ="",
                //    Available2Lend = true,
                //    Description = "",
                //    Dimensions ="",
                //    ImageUrl ="",
                //    PublishedDate = new DateTime(1,1,1)
                //},
                //new Book
                //{
                //    Id = 4,
                //    Name = "",
                //    Language ="English",
                //    ISBN = "",
                //    ISBN13 = "",
                //    Length = 0,
                //    Weight ="",
                //    Author ="",
                //    Available2Lend = true,
                //    Description = "",
                //    Dimensions ="",
                //    ImageUrl ="",
                //    PublishedDate = new DateTime(1,1,1)
                //},
                //new Book
                //{
                //    Id = 4,
                //    Name = "",
                //    Language ="English",
                //    ISBN = "",
                //    ISBN13 = "",
                //    Length = 0,
                //    Weight ="",
                //    Author ="",
                //    Available2Lend = true,
                //    Description = "",
                //    Dimensions ="",
                //    ImageUrl ="",
                //    PublishedDate = new DateTime(1,1,1)
                //},new Book
                //{
                //    Id = 4,
                //    Name = "",
                //    Language ="English",
                //    ISBN = "",
                //    ISBN13 = "",
                //    Length = 0,
                //    Weight ="",
                //    Author ="",
                //    Available2Lend = true,
                //    Description = "",
                //    Dimensions ="",
                //    ImageUrl ="",
                //    PublishedDate = new DateTime(1,1,1)
                //},
                //new Book
                //{
                //    Id = 4,
                //    Name = "",
                //    Language ="English",
                //    ISBN = "",
                //    ISBN13 = "",
                //    Length = 0,
                //    Weight ="",
                //    Author ="",
                //    Available2Lend = true,
                //    Description = "",
                //    Dimensions ="",
                //    ImageUrl ="",
                //    PublishedDate = new DateTime(1,1,1)
                //},
            };

            return(books);
        }
Exemplo n.º 8
0
        public async Task <IActionResult> Submit([FromForm] SubmittedCfp submittedCfp)
        {
            // TODO
            // Check validity
            if (ModelState.IsValid)
            {
                // Map
                var cfpToAddId = Guid.NewGuid();
                var timezone   = string.Empty;

                try
                {
                    timezone = await GetTimezone(submittedCfp.LocationLat, submittedCfp.LocationLng);
                }
                catch
                {
                    // Intentionally left blank, just for event to calendar
                    // If it fails, sucks for you
                }

                var cfpToAddSlug = FriendlyUrlHelper.GetFriendlyTitle(submittedCfp.EventTitle);
                var i            = 0;

                // Prevent duplicate slugs
                while (_cfpContext.Cfps.Any(cfp => cfp.Slug == cfpToAddSlug))
                {
                    cfpToAddSlug = $"{cfpToAddSlug}-{++i}";
                }

                var cfpToAdd = new Cfp
                {
                    Id                       = cfpToAddId,
                    EventName                = submittedCfp.EventTitle,
                    EventUrl                 = submittedCfp.EventUrl,
                    EventImage               = ValidateImageUri(submittedCfp.EventImageUrl),
                    EventDescription         = submittedCfp.EventDescription,
                    EventLocationName        = submittedCfp.LocationName,
                    EventLocationLat         = submittedCfp.LocationLat,
                    EventLocationLng         = submittedCfp.LocationLng,
                    CfpEndDate               = submittedCfp.CfpEndDate.Date,
                    CfpAdded                 = DateTime.Now,
                    CfpUrl                   = submittedCfp.CfpUrl,
                    EventStartDate           = submittedCfp.EventStartDate?.Date ?? default(DateTime),
                    EventEndDate             = submittedCfp.EventEndDate?.Date ?? default(DateTime),
                    ProvidesAccommodation    = submittedCfp.ProvidesAccommodation,
                    ProvidesTravelAssistance = submittedCfp.ProvidesTravelAssistance,
                    SubmittedByName          = submittedCfp.SubmittedByName,
                    EventTwitterHandle       = submittedCfp.EventTwitterHandle,
                    EventTimezone            = timezone,
                    Slug                     = cfpToAddSlug,
                    EventTags                = submittedCfp.EventTags,
                    CfpDecisionDate          = submittedCfp.CfpDecisionDate?.Date ?? default(DateTime)
                };

                // Save CFP
                _cfpContext.Add(cfpToAdd);
                await _cfpContext.SaveChangesAsync();

                if (ShouldDownloadEventImageLocally())
                {
                    await _downloadEventImageMessageSender.Execute(cfpToAddId, submittedCfp.EventImageUrl);
                }

                // Post to Twitter account
                try
                {
                    await PostNewCfpTweet(cfpToAdd);
                }
                catch
                {
                    // Intentionally left blank, we can probably do something
                    // more useful, but for now if Twitter fails  ¯\_(ツ)_/¯
                }

                // Send back ID to do whatever at the client-side
                return(Json(cfpToAddId));
            }

            // Add invalid model
            return(BadRequest(submittedCfp));
        }
Exemplo n.º 9
0
        public void GetFriendlyTitle_WithShortTitle_ShouldReturnSimilarString()
        {
            var result = FriendlyUrlHelper.GetFriendlyTitle(TITLE_TWENTY_CHARACTERS);

            Assert.Equal(URL_TWENTY_CHARACTERS, result);
        }
Exemplo n.º 10
0
        public static void EnsureSeeded(this CfpContext context)
        {
            if (context.Cfps.CountAsync().Result == 0)
            {
                context.Cfps.Add(new Cfp
                {
                    EventName                = "Techorama BE",
                    Id                       = Guid.NewGuid(),
                    Views                    = 100,
                    CfpAdded                 = DateTime.Now.AddDays(-10),
                    SubmittedByName          = "Gerald",
                    EventLocationName        = "Antwerp, Belgium",
                    EventDescription         = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
                    CfpEndDate               = DateTime.Now.AddDays(100),
                    CfpUrl                   = "http://www.example.com",
                    EventUrl                 = "https://www.techorama.be",
                    EventImage               = "https://techorama.nl/wp-content/uploads/sites/2/2017/10/[email protected]",
                    EventStartDate           = DateTime.Now.AddDays(1),
                    EventEndDate             = DateTime.Now.AddDays(2),
                    ProvidesAccommodation    = Accommodation.Unknown,
                    ProvidesTravelAssistance = TravelAssistence.Yes,
                    Slug                     = "techorama-be",
                    EventTags                = ".NET;Awesome;Unicorns"
                });

                context.Cfps.Add(new Cfp
                {
                    EventName                = "Techorama NL",
                    Id                       = Guid.NewGuid(),
                    Views                    = 10,
                    CfpAdded                 = DateTime.Now,
                    SubmittedByName          = "Gerald",
                    EventLocationName        = "Ede, The Netherlands",
                    EventDescription         = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
                    CfpEndDate               = DateTime.Now.AddDays(10),
                    EventImage               = "https://techorama.nl/wp-content/uploads/sites/2/2017/10/[email protected]",
                    EventStartDate           = DateTime.Now.AddMonths(1),
                    EventEndDate             = DateTime.Now.AddMonths(1).AddDays(2),
                    ProvidesAccommodation    = Accommodation.No,
                    ProvidesTravelAssistance = TravelAssistence.Unknown,
                    Slug                     = "techorama-nl",
                    EventTags                = ".NET;Awesome;Unicorns;Dutch"
                });

                context.Cfps.Add(new Cfp
                {
                    EventName                = "NDC Minnesota",
                    Id                       = Guid.NewGuid(),
                    Views                    = 15,
                    CfpAdded                 = DateTime.Now,
                    SubmittedByName          = "Gerald",
                    EventLocationName        = "Minnesota, USA",
                    EventDescription         = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
                    CfpEndDate               = DateTime.Now.AddDays(1),
                    ProvidesAccommodation    = Accommodation.Yes,
                    ProvidesTravelAssistance = TravelAssistence.Yes,
                    Slug                     = "ndc-minnesota",
                    EventTags                = ".NET;Awesome;Unicorns;PubConf",
                    IsVirtual                = true
                });

                // Give this one a static GUID to be able to access it
                context.Cfps.Add(new Cfp
                {
                    EventName                = "NDC London",
                    Id                       = new Guid("d238d46f-055a-44fd-ad99-840a4741635f"),
                    Views                    = 23,
                    CfpAdded                 = DateTime.Now,
                    SubmittedByName          = "Gerald",
                    EventLocationName        = "London, UK",
                    EventLocationLat         = 51.5073509,
                    EventLocationLng         = -0.127758299999982,
                    EventDescription         = "Lorem ipsum dolor sit amet, consectetur adipiscing elit2.",
                    CfpEndDate               = DateTime.Now.AddHours(-24),
                    ProvidesAccommodation    = Accommodation.No,
                    ProvidesTravelAssistance = TravelAssistence.No,
                    Slug                     = "ndc-london",
                    EventTags                = ".NET;Awesome;Unicorns;Bla"
                });

                context.Cfps.Add(new Cfp
                {
                    EventName         = "NDC Oslo",
                    Id                = Guid.NewGuid(),
                    Views             = 34,
                    CfpAdded          = DateTime.Now,
                    SubmittedByName   = "Gerald",
                    EventLocationName = "Oslo, Norway",
                    EventDescription  = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
                    CfpEndDate        = DateTime.Now.AddDays(20),
                    EventTags         = ".NET;Awesome;Unicorns;Cold"
                });

                // Give this one a static GUID to be able to access it
                context.Cfps.Add(new Cfp
                {
                    EventName                = "SDN Event",
                    Id                       = new Guid("dd3f7150-c9a7-46ed-9481-9246aed2329d"),
                    Views                    = 42,
                    CfpAdded                 = DateTime.Now,
                    SubmittedByName          = "Gerald",
                    EventLocationName        = "Zeist, The Netherlands",
                    EventDescription         = "Lorem ipsum dolor sit amet, consectetur adipiscing elit2.",
                    CfpEndDate               = DateTime.Now.AddDays(7),
                    ProvidesAccommodation    = Accommodation.Unknown,
                    ProvidesTravelAssistance = TravelAssistence.Unknown,
                    Slug                     = "sdn-event",
                    EventTags                = ""
                });

                // Give this one a static GUID to be able to access it
                context.Cfps.Add(new Cfp
                {
                    EventName                = "SDN Event duplicate",
                    Id                       = new Guid("30eb1e5c-5959-4685-b2bb-36d816023007"),
                    Views                    = 3,
                    CfpAdded                 = DateTime.Now,
                    SubmittedByName          = "Gerald",
                    EventLocationName        = "Zeist, The Netherlands",
                    EventDescription         = "Lorem ipsum dolor sit amet, consectetur adipiscing elit1.",
                    CfpEndDate               = DateTime.Now.AddDays(4),
                    ProvidesAccommodation    = Accommodation.Unknown,
                    ProvidesTravelAssistance = TravelAssistence.Unknown,
                    DuplicateOfId            = new Guid("dd3f7150-c9a7-46ed-9481-9246aed2329d"),
                    Slug                     = "sdn-event-1",
                    EventTags                = ".NET;Awesome;Unicorns;SDN"
                });

                context.SaveChanges();
            }

            // Ensure all cfps have a slug
            var cfpsWithoutSlug = context.Cfps.Where(cfp => string.IsNullOrWhiteSpace(cfp.Slug));

            if (cfpsWithoutSlug.Any())
            {
                foreach (var cfp in cfpsWithoutSlug)
                {
                    cfp.Slug = FriendlyUrlHelper.GetFriendlyTitle(cfp.EventName);
                }

                context.SaveChanges();
            }
        }
Exemplo n.º 11
0
        public void GetFriendlyTitle_RemapToAscii_ReturnsExpectedFriendlyTitle(string title, string expectedFriendlyTitle)
        {
            var actualFriendlyTitle = FriendlyUrlHelper.GetFriendlyTitle(title, true, 100);

            Assert.Equal(expectedFriendlyTitle, actualFriendlyTitle);
        }
Exemplo n.º 12
0
 public static string Slug(string title)
 {
     return(FriendlyUrlHelper.GetFriendlyTitle(title));
 }
Exemplo n.º 13
0
        public void Test1()
        {
            string url = FriendlyUrlHelper.GetFriendlyTitle("Hứa Đại Thắng");

            Console.WriteLine(url);
        }
Exemplo n.º 14
0
        public void GetFriendlyTitle_WithTitleEmpty_ShouldReturnEmptyString()
        {
            var result = FriendlyUrlHelper.GetFriendlyTitle(string.Empty);

            Assert.Equal(string.Empty, result);
        }
Exemplo n.º 15
0
        public async Task <IActionResult> ArticleSingle(int id, string title)
        {
            var    article       = _context.Article.Where(x => x.Id == id).SingleOrDefault();
            string currentUserId = await OnGetSesstion();

            if (article == null)
            {
                return(NotFound());
            }
            if (article.Status == "history")
            {
                article = _context.Article.Where(re => re.OriginalId == article.OriginalId && re.Status == "active").SingleOrDefault();
            }
            string friendlyTitle = FriendlyUrlHelper.GetFriendlyTitle(article.Title);

            if (!string.Equals(friendlyTitle, title, StringComparison.Ordinal))
            {
                // If the title is null, empty or does not match the friendly title, return a 301 Permanent
                // Redirect to the correct friendly URL.
                return(this.RedirectToRoutePermanent("ArticleSingle", new { id = id, title = friendlyTitle }));
            }
            var articleVM = _mapper.Map <SingleArticleVM>(article);

            if (article.Id != article.OriginalId)
            {
                articleVM.IsEdited = true;
            }
            else
            {
                articleVM.IsEdited = false;
            }
            //Get Article Tags Ids
            var arttags = _context.ArticleTag.Where(tg => tg.ArticleId == article.Id).ToList();

            articleVM.Tags = new List <SkillTag>();
            foreach (var arttag in arttags)
            {
                var singleTag = _context.SkillTag.Where(sktag => sktag.SkillTagId == arttag.TagId).SingleOrDefault();
                articleVM.Tags.Add(singleTag);
            }
            //Author

            var author = _context.UserPersonalDetail.Where(usr => usr.UserId == article.UserId).SingleOrDefault();

            articleVM.AuthorUserName = _userManager.Users.Where(x => x.Id == author.UserId).Select(y => y.UserName).SingleOrDefault();
            articleVM.AuthorId       = author.UserId;
            articleVM.AuthorImg      = author.ProfileImage;
            articleVM.AuthorName     = author.FirstName + " " + author.LastName;
            articleVM.AuthorSummary  = author.Summary;
            articleVM.CommentsCount  = _context.ArticleComment.Where(cmt => cmt.ArticleId == article.OriginalId).Count();
            articleVM.VisitorsCount  = _context.ArticleVisitor.Where(av => av.ArticleId == article.OriginalId).Count();
            if (currentUserId != null)
            {
                if (articleVM.AuthorId == currentUserId)
                {
                    articleVM.IsArticleAuthor = true;
                }
                else
                {
                    articleVM.IsArticleAuthor = false;
                }
            }
            else
            {
                articleVM.IsArticleAuthor = false;
            }
            return(View("ArticleSingle", articleVM));
        }
Exemplo n.º 16
0
        public void GetFriendlyTitle_WithNonAsciiCharactersRemap_ShouldReturnStringWithoutNonAsciiCharacters()
        {
            var result = FriendlyUrlHelper.GetFriendlyTitle(NON_ASII_CHARACTERS, true);

            Assert.Equal(URL_ASII_CHARACTERS, result);
        }
Exemplo n.º 17
0
        public void GetFriendlyTitle_WithTitleDisallowedCharacters_ShouldReturnStringWithoutDisallowedCharacters()
        {
            var result = FriendlyUrlHelper.GetFriendlyTitle(ALL_DISALLOWED_CHARACTERS);

            Assert.Equal(URL_DISALLOWED_CHARACTERS, result);
        }
Exemplo n.º 18
0
        public void GetFriendlyTitle_WithLongTitle_ShouldReturnTrimmedString()
        {
            var result = FriendlyUrlHelper.GetFriendlyTitle(TITLE_NINETY_CHARACTERS);

            Assert.Equal(URL_NINETY_CHARACTERS, result);
        }
Exemplo n.º 19
0
        public void GetFriendlyTitle_WithShortTitleAndMaxLength_ShouldReturnSimilarStringWithinMaxLength()
        {
            var result = FriendlyUrlHelper.GetFriendlyTitle(TITLE_TWENTY_CHARACTERS, maxlength: 10);

            Assert.Equal(URL_TWENTYTEN_CHARACTERS, result);
        }