Ejemplo n.º 1
0
        public Exhibitor AddExhibitor(Exhibitor exhibitor)
        {
            Exhibitor returnE = _exhibitorRepository.Add(exhibitor);

            _exhibitorRepository.SaveChanges();
            return(returnE);
        }
Ejemplo n.º 2
0
        private Exhibitor MapExhibitor(Exhibitor exhibitor)
        {
//            var categoryExhibitors = exhibitor?.Categories;
//            categoryExhibitors?.ForEach(ce =>
//            {
//                ce.Exhibitor.Categories = null;
//                ce.Category.Exhibitors = null;
//            });
            var exh = new Exhibitor
            {
                Id   = exhibitor.Id,
                Name = exhibitor.Name,
                X    = exhibitor.X,
                Y    = exhibitor.Y,
                GroupsAtExhibitor = exhibitor.GroupsAtExhibitor,
                Categories        = exhibitor.Categories.Select(ce => new CategoryExhibitor
                {
                    CategoryId = ce.CategoryId,
                    Category   = new Category
                    {
                        Id          = ce.Category.Id,
                        Name        = ce.Category.Name,
                        Photo       = ce.Category.Photo,
                        Description = ce.Category.Description
                    }
                }).ToList(),
                ExhibitorNumber = exhibitor.ExhibitorNumber
            };

            return(exh);
        }
Ejemplo n.º 3
0
 public void SetParameters(string name, string description, string size, Exhibitor exhibitor)
 {
     Name        = name;
     Description = description;
     SetDimension(size);
     Exhibitor = exhibitor;
 }
        public async Task <Exhibitor> DeleteExhibitorAsync(Exhibitor exhibitor2BDeleted)
        {
            _context.Exhibitors.Remove(exhibitor2BDeleted);
            await _context.SaveChangesAsync();

            return(exhibitor2BDeleted);
        }
        public async Task <ActionResult> Create(Exhibitor exhibitor, List <int> events, HttpPostedFileBase thumbnail)
        {
            try
            {
                // TODO: Add insert logic here
                string fileName = string.Empty;
                if (thumbnail != null)
                {
                    fileName = Guid.NewGuid().ToString() + ".png";
                }
                exhibitor.Thumbnail = fileName;
                await exhibitorLogic.AddUpdateExhibitors(exhibitor, events);

                if (thumbnail != null)
                {
                    thumbnail.SaveAs(Path.Combine(ImageSavePath, fileName));
                }
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                Helpers.LogError("Exhibitor Error", ex);
                //EventLogic eventLogic = new EventLogic();
                ViewBag.Events = await eventlogic.GetAllEvents();

                ViewBag.Error = Literals.ErrorMessage;
                return(View(exhibitor));
            }
        }
Ejemplo n.º 6
0
        public static string SponsorImage(this UrlHelper urlHelper, Exhibitor sponsor)
        {
            var slug     = sponsor.Name.CleanSlug();
            var cacheKey = "sponsorimage:" + ":" + slug;
            var result   = urlHelper.RequestContext.HttpContext.Cache.Get(cacheKey) as string;

            if (string.IsNullOrEmpty(result))
            {
                foreach (var ext in new[] { "jpg", "gif", "png" })
                {
                    var imagePath = string.Format("~/Content/images/sponsors/{0}.{1}", slug, ext);
                    var filePath  = urlHelper.RequestContext.HttpContext.Server.MapPath(imagePath);
                    var exists    = System.IO.File.Exists(filePath);
                    if (!exists)
                    {
                        continue;
                    }

                    result = VirtualPathUtility.ToAbsolute(imagePath);
                    urlHelper.RequestContext.HttpContext.Cache.Add(cacheKey, result, null, DateTime.Now.AddHours(1),
                                                                   Cache.NoSlidingExpiration, CacheItemPriority.Normal, null);

                    break;
                }
            }
            if (result == "")
            {
                result = null;
            }

            return(result);
        }
        private static List <Exhibitor> ParseExhibitors(HtmlAgilityPack.HtmlNodeCollection nodes, bool isFeatured)
        {
            List <Exhibitor> exhibitors = new List <Exhibitor>();

            foreach (HtmlAgilityPack.HtmlNode node in nodes)
            {
                Exhibitor exhibitor = new Exhibitor();
                exhibitor.DetailUrl  = node.SelectSingleNode("div[2]/h3/a").Attributes["href"].Value;
                exhibitor.Name       = node.SelectSingleNode("div[2]/h3/a").InnerText.Trim();
                exhibitor.IsFeatured = isFeatured;

                string[] cityCountry = node.SelectSingleNode("div[2]/div/h4").InnerText.Split(',');
                if (cityCountry.Length >= 2)
                {
                    exhibitor.City    = cityCountry[0].Trim();
                    exhibitor.Country = cityCountry[1].Trim();
                }

                var locationNodes = node.SelectNodes("div[3]/ul/li");
                if (locationNodes != null)
                {
                    List <string> locations = new List <string>();

                    foreach (var l in locationNodes)
                    {
                        locations.Add(string.Concat("Hall ", l.InnerText));
                    }

                    exhibitor.Locations = string.Join(", ", locations.ToArray());
                }
                exhibitors.Add(exhibitor);
            }
            return(exhibitors);
        }
Ejemplo n.º 8
0
        public ActionResult Edit(EventAddress eventAddress, string exhibitorSlug)
        {
            var userAuthenticated = userService.GetUser(User.Identity.Name);

            if (userAuthenticated == null || !userAuthenticated.IsInRole("Admin"))
            {
                return(null);
            }

            var slug = exhibitorSlug.CleanSlug();

            Exhibitor exhibitor;

            if (slug.Equals("New"))
            {
                exhibitor = new Exhibitor(Guid.Empty);
            }
            else
            {
                var exhibitorFilterCriteria = new ExhibitorFilterCriteria {
                    Term = slug
                };

                var result = exhibitorService.GetExhibitors(eventAddress, exhibitorFilterCriteria);

                exhibitor = result.SingleOrDefault();
            }

            if (exhibitor == null)
            {
                return(null);
            }

            return(View(new OxiteViewModelItem <Exhibitor>(exhibitor)));
        }
Ejemplo n.º 9
0
        public void CalculateTest(double first, double expected)
        {
            var calculator   = new Exhibitor();
            var actualResult = calculator.Calculate(first);

            Assert.AreEqual(expected, actualResult, 0.0001);
        }
Ejemplo n.º 10
0
        public async Task <Exhibitor> RemoveExhibitor(int id)
        {
            Exhibitor exhibitor = await _exhibitorRepository.GetById(id);

            _exhibitorRepository.Remove(exhibitor);
            _exhibitorRepository.SaveChanges();
            return(exhibitor);
        }
        public async Task <Exhibitor> AddExhibitorAsync(Exhibitor newExhibitor)
        {
            await _context.Exhibitors.AddAsync(newExhibitor);

            await _context.SaveChangesAsync();

            return(newExhibitor);
        }
        public async Task <Exhibitor> UpdateExhibitorAsync(Exhibitor exhibitor2BUpdated)
        {
            Exhibitor oldExhibitor = await _context.Exhibitors.Where(b => b.Id == exhibitor2BUpdated.Id).FirstOrDefaultAsync();

            _context.Entry(oldExhibitor).CurrentValues.SetValues(exhibitor2BUpdated);
            await _context.SaveChangesAsync();

            _context.ChangeTracker.Clear();
            return(oldExhibitor);
        }
Ejemplo n.º 13
0
        /**
         * value that reflects the weight, holding in account the distance and number of groups standing
         * at the exhibitor, as measure of potential.
         */
        private double GetWeight(Exhibitor exhibitor, double startX, double startY)
        {
            // Distance compared to current exhibitors' position.
            var distance = Math.Abs(startX - exhibitor.X) + Math.Abs(startY - exhibitor.Y);
            // value that reflects the weight, holding in account the distance and number of groups standing
            // at the exhibitor, as measure of potential.
            var weight = (int)(distance + Math.Pow(distance, exhibitor.GroupsAtExhibitor));

            return(weight);
        }
Ejemplo n.º 14
0
        public void RemoveExhibitor(EventAddress eventAddress, Exhibitor exhibitor)
        {
            using (var transaction = new TransactionScope())
            {
                repository.RemoveExhibitor(eventAddress, exhibitor);

                transaction.Complete();
            }

            cache.InvalidateItem(exhibitor);
        }
        private async Task <Question> GetQuestion(Exhibitor exhibitor, int categoryId)
        {
            var questions = await _questionRepository.GetAll();

            //Todo: methode in repo maken die via beide id's (als parameter meegegeven) de question ophaalt.
            var question = questions.First(q => q.CategoryExhibitor.CategoryId == categoryId &&
                                           q.CategoryExhibitor.ExhibitorId ==
                                           exhibitor.Id);

            return(question);
        }
Ejemplo n.º 16
0
        public async Task <IActionResult> Edit(Exhibitor model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            _dbContext.Update(model);
            await _dbContext.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Ejemplo n.º 17
0
        public async Task <Exhibitor> UpdateExhibitor(Exhibitor exhibitor)
        {
            Exhibitor e = await _exhibitorRepository.GetById(exhibitor.Id);

            e.Name            = exhibitor.Name;
            e.X               = exhibitor.X;
            e.Y               = exhibitor.Y;
            e.Categories      = exhibitor.Categories;
            e.ExhibitorNumber = exhibitor.ExhibitorNumber;

            _exhibitorRepository.SaveChanges();
            return(exhibitor);
        }
 public override void ViewWillAppear(bool animated)
 {
     base.ViewWillAppear(animated);
     exhibitor = BL.Managers.ExhibitorManager.GetExhibitor(exhibitorId);
     // shouldn't be null, but it gets that way when the data
     // "shifts" underneath it. need to reload the screen or prevent
     // selection via loading overlay - neither great UIs :-(
     LayoutSubviews();
     if (exhibitor != null)
     {
         Update();
     }
 }
Ejemplo n.º 19
0
        public async Task <IActionResult> UpdateExhibitorAsync(Guid id, [FromBody] Exhibitor exhibitor)
        {
            try
            {
                await _exhibitorBL.UpdateExhibitorAsync(exhibitor);

                return(NoContent());
            }
            catch
            {
                return(StatusCode(500));
            }
        }
Ejemplo n.º 20
0
        public async Task <IActionResult> AddExhibitorAsync([FromBody] Exhibitor exhibitor)
        {
            try
            {
                await _exhibitorBL.AddExhibitorAsync(exhibitor);

                return(CreatedAtAction("AddExhibitor", exhibitor));
            }
            catch (Exception e)
            {
                return(StatusCode(400));
            }
        }
Ejemplo n.º 21
0
        public static IEnumerable <ICacheEntity> GetDependencies(this Exhibitor exhibitor)
        {
            List <ICacheEntity> dependencies = new List <ICacheEntity>();

            if (exhibitor == null)
            {
                return(dependencies);
            }

            dependencies.Add(exhibitor);

            return(dependencies);
        }
Ejemplo n.º 22
0
        public Exhibitor AddExhibitor([FromBody] ExhibitorDTO exhibitordto)
        {
            var exhibitor = new Exhibitor
            {
                Name            = exhibitordto.Name,
                ExhibitorNumber = exhibitordto.ExhibitorNumber,
                X = exhibitordto.X,
                Y = exhibitordto.Y,
                GroupsAtExhibitor = 0,
                Categories        = CreateCategories(exhibitordto.CategoryIds)
            };

            return(_exhibitorManager.AddExhibitor(exhibitor));
        }
        // GET: Exhibitors/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Exhibitor exhibitor = await exhibitorLogic.GetExhibitorsById(id.Value);

            if (exhibitor == null)
            {
                return(HttpNotFound());
            }
            return(View(exhibitor));
        }
Ejemplo n.º 24
0
        public Task <Exhibitor> UpdateExhibitor([FromBody] ExhibitorDTO exhibitordto)
        {
            var exhibitor = new Exhibitor
            {
                Id              = exhibitordto.Id,
                Name            = exhibitordto.Name,
                ExhibitorNumber = exhibitordto.ExhibitorNumber,
                X = exhibitordto.X,
                Y = exhibitordto.Y,
                GroupsAtExhibitor = 0,
                Categories        = CreateCategories(exhibitordto.CategoryIds)
            };

            return(_exhibitorManager.UpdateExhibitor(exhibitor));
        }
Ejemplo n.º 25
0
        /**
         * Finds the "fittest" Exhibitor, holding in account how occupied with visitors and far the exhibitors are.
         */
        public async Task <Exhibitor> FindNextExhibitor(int exhibitorIdStart, int categoryId)
        {
            Exhibitor start = null;

            // The first time the tour starts, the exhibitorId will be -1
            if (exhibitorIdStart != -1)
            {
                start = await _exhibitorRepository.GetById(exhibitorIdStart);
            }

            double startX;
            double startY;

            if (start == null)
            {
                startX = new Random().NextDouble(); //Center of map
                startY = new Random().NextDouble();
            }
            else
            {
                startX = start.X;
                startY = start.Y;
            }

            /*Todo enkel categoryExhibitor objecten nemen waaraan een question verbonden is. en een methode in de repo daarvoor voorzien.*/
            var questions = await _questionRepository.GetAll();

            var potentialExhibitors =
                questions.Where(q => q.CategoryExhibitor.CategoryId == categoryId)
                .Select(e => e.CategoryExhibitor.Exhibitor)
                .ToList();
            var nextExhibitor = potentialExhibitors[0];

            potentialExhibitors.RemoveAt(0);
            var lowestWeight = GetWeight(nextExhibitor, startX, startY);

            potentialExhibitors.ForEach(e =>
            {
                var weight = GetWeight(e, startX, startY);

                if (weight < lowestWeight)
                {
                    lowestWeight  = weight;
                    nextExhibitor = e;
                }
            });
            return(nextExhibitor);
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.ExhibitorDetailsScreen);

            var id = Intent.GetIntExtra("ExhibitorID", -1);

            if (id >= 0)
            {
                exhibitor = BL.Managers.ExhibitorManager.GetExhibitor(id);
                if (exhibitor != null)
                {
                    FindViewById <TextView>(Resource.Id.NameTextView).Text     = exhibitor.Name;
                    FindViewById <TextView>(Resource.Id.CountryTextView).Text  = exhibitor.FormattedCityCountry;
                    FindViewById <TextView>(Resource.Id.LocationTextView).Text = exhibitor.Locations;
                    if (!String.IsNullOrEmpty(exhibitor.Overview))
                    {
                        FindViewById <TextView>(Resource.Id.DescriptionTextView).Text = exhibitor.Overview;
                    }
                    else
                    {
                        FindViewById <TextView>(Resource.Id.DescriptionTextView).Text = "No background information available.";
                    }
                    // now do the image
                    imageview = FindViewById <ImageView>(Resource.Id.ExhibitorImageView);
                    var uri = new Uri(exhibitor.ImageUrl);
                    Console.WriteLine("speaker.ImageUrl " + exhibitor.ImageUrl);
                    try {
                        var drawable = MonoTouch.Dialog.Utilities.ImageLoader.DefaultRequestImage(uri, this);
                        if (drawable != null)
                        {
                            imageview.SetImageDrawable(drawable);
                        }
                    } catch (Exception ex) {
                        Console.WriteLine(ex.ToString());
                    }
                }
                else       // shouldn't happen...
                {
                    FindViewById <TextView>(Resource.Id.NameTextView).Text = "Exhibitor not found: " + id;
                }
            }
        }
        public void RemoveExhibitor(EventAddress eventAddress, Exhibitor exhibitor)
        {
            oxite_Conferences_Exhibitor exhibitorToRemove = null;

            if (exhibitor.ID != Guid.Empty)
            {
                exhibitorToRemove = context
                                    .oxite_Conferences_Exhibitors
                                    .FirstOrDefault(c => c.ExhibitorID == exhibitor.ID);
            }

            if (exhibitorToRemove == null)
            {
                return;
            }

            context.oxite_Conferences_Exhibitors.DeleteOnSubmit(exhibitorToRemove);
            context.SubmitChanges();
        }
        public Exhibitor SaveExhibitor(EventAddress eventAddress, Exhibitor exhibitor)
        {
            oxite_Conferences_Exhibitor exhibitorToSave = null;

            if (exhibitor.ID != Guid.Empty)
            {
                exhibitorToSave = context
                                  .oxite_Conferences_Exhibitors
                                  .FirstOrDefault(c => c.ExhibitorID == exhibitor.ID);
            }

            if (exhibitorToSave == null)
            {
                exhibitorToSave = new oxite_Conferences_Exhibitor
                {
                    EventID          = exhibitor.EventID,
                    Name             = exhibitor.Name,
                    ParticipantLevel = "Exhibitor",
                    CreatedDate      = DateTime.UtcNow,
                    ModifiedDate     = DateTime.UtcNow
                };

                context.oxite_Conferences_Exhibitors.InsertOnSubmit(exhibitorToSave);
            }
            else
            {
                exhibitorToSave.ModifiedDate = DateTime.UtcNow;
            }

            exhibitorToSave.Name             = exhibitor.Name;
            exhibitorToSave.Description      = exhibitor.Description;
            exhibitorToSave.SiteUrl          = exhibitor.SiteUrl;
            exhibitorToSave.LogoUrl          = exhibitor.LogoUrl;
            exhibitorToSave.ParticipantLevel = exhibitor.ParticipantLevel;
            exhibitorToSave.ContactName      = exhibitor.ContactName;
            exhibitorToSave.ContactEmail     = exhibitor.ContactEmail;

            context.SubmitChanges();

            return(projectExhibitor(exhibitorToSave));
        }
Ejemplo n.º 29
0
        public void Update(Exhibitor exhibitor)
        {
            ID         = exhibitor.ID;
            Name       = exhibitor.Name;
            City       = exhibitor.City;
            Country    = exhibitor.Country;
            Locations  = exhibitor.Locations;
            IsFeatured = exhibitor.IsFeatured;
            Overview   = CleanupPlainTextDocument(exhibitor.Overview);
            Tags       = exhibitor.Tags;
            Email      = exhibitor.Email;
            Address    = exhibitor.Address;
            Phone      = exhibitor.Phone;
            Fax        = exhibitor.Fax;
            ImageUrl   = exhibitor.ImageUrl;

            if (string.IsNullOrWhiteSpace(Overview))
            {
                Overview = "No background information available.";
            }
        }
Ejemplo n.º 30
0
        public static List <Exhibitor> getLocalExhibitorList()
        {
            List <Exhibitor> exhList = new List <Exhibitor>();
            List <string>    strList = LocalLists.getExhibitorList();
            Dictionary <string, SponsorType> dict = getLocalSponsorDictionary();

            foreach (string s in strList)
            {
                string[]  items = s.Split(';');
                Exhibitor exh   = new Exhibitor();
                exh.Title         = items[0].Trim();
                exh.SponsorTypeId = items[1].Trim();
                exh.Icon          = items[2].Trim();
                exh.Id            = Guid.NewGuid().ToString();
                exh.CreatedAtTime = DateTime.Now;
                exh.UpdatedAtTime = DateTime.Now;
                exh.SponsorType   = dict[exh.SponsorTypeId];
                exhList.Add(exh);
            }
            return(exhList);
        }