public IActionResult JoinEvent(int eventID)
        {
            MemberRepo memRP   = new MemberRepo(_context);
            EventRepo  eventRP = new EventRepo(_context);

            var    claim  = HttpContext.User.Claims.ElementAt(0);
            string email  = claim.Value;
            var    member = memRP.GetOneByEmail(email);

            try
            {
                eventRP.JoinEvent(eventID, member.Id);

                var responseObject = new
                {
                    StatusCode = "Added to the list",
                };
                return(new ObjectResult(responseObject));
            }
            catch
            {
                var responseObject = new
                {
                    error = "can't added again",
                };
                return(new ObjectResult(responseObject));
            }
        }
Esempio n. 2
0
        private EventSearchModel Search(EventSearchModel model)
        {
            var query = EventRepo.GetAll().Where(x => x.UserId == currentUser.Id);

            if (!string.IsNullOrEmpty(model.SearchTitle))
            {
                query = query.Where(x => x.Title.Contains(model.SearchTitle));
            }

            if (model.SearchProvinceId.HasValue)
            {
                query = query.Where(x => x.City.provinceId == model.SearchProvinceId);
            }

            if (model.SearchCityId.HasValue)
            {
                query = query.Where(x => x.CityId == model.SearchCityId);
            }


            model.TotalItems = query.Count();

            var result = query.OrderBy(x => x.Createdate)
                         .Skip((model.CurrentPage - 1) * model.PageSize)
                         .Take(model.PageSize)
                         //.ToModel()
                         .ToList();

            model.Events = result;

            return(model);
        }
        public IActionResult Delete(int eventID)
        {
            try
            {
                EventRepo eventRP = new EventRepo(_context);
                eventRP.Delete(eventID);
                var Obj = new
                {
                    StatusCode = "ok",
                    message    = "Deleted"
                };

                return(new ObjectResult(Obj));
            }
            catch
            {
                var Obj = new
                {
                    StatusCode = "error",
                    message    = "Somebody in the event."
                };

                return(new ObjectResult(Obj));
            }
        }
Esempio n. 4
0
        public void AddEventTrue()
        {
            EventRepo eventRepo = new EventRepo();
            DateTime  dateTime  = DateTime.Parse("10/31/2020");

            Assert.IsTrue(eventRepo.AddEvent(Events.AmusementPark, 50, dateTime, 12250.50m));
        }
Esempio n. 5
0
        public void TestInit()
        {
            _repo = new EventRepo();

            dateOne   = new DateTime(2001, 5, 12);
            dateTwo   = new DateTime(3005, 11, 30);
            dateThree = new DateTime(1992, 2, 21);
            dateFour  = new DateTime(2020, 4, 11);
            dateFive  = new DateTime(1999, 12, 31);
            dateSix   = new DateTime(2011, 1, 5);

            eventOne   = new Event(EventTypes.AmusementPark, 21, dateOne, 3478.29478);
            eventTwo   = new Event(EventTypes.AmusementPark, 70, dateTwo, 37562.12345);
            eventThree = new Event(EventTypes.Bowling, 4, dateThree, 90.73625);
            eventFour  = new Event(EventTypes.Concert, 18, dateFour, 222.421273);
            eventFive  = new Event(EventTypes.Golf, 3, dateFive, 99999.999999);
            eventSix   = new Event(EventTypes.Bowling, 99, dateSix, 10);

            _repo.CreateNewEvent(eventOne);
            _repo.CreateNewEvent(eventTwo);
            _repo.CreateNewEvent(eventThree);
            _repo.CreateNewEvent(eventFour);
            _repo.CreateNewEvent(eventFive);
            _repo.CreateNewEvent(eventSix);
        }
Esempio n. 6
0
    public void GetsDataFromDataBaseIfNotCachedTest()
    {
        var cacheProvider = new Mock <ICacheProvider>(MockBehavior.Strict);

        cacheProvider
        .Setup(x => x.IsDataCached())
        .Returns(() =>
        {
            return(false);
        });
        cacheProvider
        .Setup(x => x.GetFromCache())
        .Returns(
            () =>
        {
            return(new Event[] {
                new Event()
                {
                    Id = 1
                },
                new Event()
                {
                    Id = 2
                }
            });
        }
            );
        var eventRepo = new EventRepo(cacheProvider.Object);
        var data      = eventRepo.GetAll();

        cacheProvider.Verify(x => x.GetFromCache(), Times.Never());
    }
Esempio n. 7
0
        public async Task <IActionResult> Pay(int id, byte count = 1)
        {
            var eventt = await EventRepo.GetById(id);

            if (eventt.TickLeft >= count)
            {
                var purchase = new Purchase();
                purchase.UserId  = currentUser.Id;
                purchase.Count   = count;
                purchase.EventId = eventt.Id;

                try
                {
                    await PurchaseRepo.Add(purchase);

                    return(message(MessageType.success));
                }

                catch
                {
                    return(message(MessageType.danger));
                }
            }

            return(message("ظرفیت کمتر از تعداد درخواست شماست", MessageType.danger));
        }
Esempio n. 8
0
        public PartialViewResult GetResultsBasedOnSearch(EventResultsSearch searchingModel, string datepicker, string postcodeH, string pageNumber = "1")
        {
            int page = int.Parse(pageNumber);

            searchingModel.SearchCriteria.PagingInformation.CurrentPage = page;

            var repo = new EventRepo(new EventMapContext());

            if (postcodeH != null)
            {
                if (postcodeH.Trim().Length != 0)
                {
                    string[] strings = postcodeH.Split(',');
                    searchingModel.SearchCriteria.PostCode = new LatLong(double.Parse(strings[0]),
                                                                         double.Parse(strings[1]));
                }
            }
            string json = "";
            IEnumerable <EventDto> results = repo.FindEventWithSearchModel(searchingModel.SearchCriteria, out json);

            EventResultsSearch eventResultsSearch = new EventResultsSearch(results, searchingModel.SearchCriteria);

            ViewBag.Json = json;
            return(PartialView("_GetResultsBasedOnSearch", eventResultsSearch));                        /*results.ToList())*/
        }
Esempio n. 9
0
        public async Task <IActionResult> OnPostAsync([FromBody] Event Event)
        {
            if (ModelState.IsValid)
            {
                EventRepo e      = new EventRepo(_context);
                var       result = e.Create(Event.EventName, Event.Description, Event.Date, Event.Time);
                if (result)
                {
                    var res = new
                    {
                        StatusCode = "Ok",
                        EventName  = Event.EventName
                    };

                    return(new ObjectResult(res));
                }
            }


            var invalidRes = new
            {
                StatusCode = "Invalid",
                EventName  = Event.EventName
            };


            return(new ObjectResult(invalidRes));
        }
Esempio n. 10
0
        public IActionResult CancelAttendance(int EventID)
        {
            AttendeeRepo c     = new AttendeeRepo(_context);
            EventRepo    e     = new EventRepo(_context);
            var          claim = HttpContext.User.Claims.ElementAt(0);
            string       email = claim.Value;
            var          user  = c.GetOneByEmail(email);

            try
            {
                e.CancelAttendance(EventID, user.ID);
                var res = new
                {
                    StatusCode = "You are no longer attending this event",
                };
                return(new ObjectResult(res));
            }
            catch
            {
                var res = new
                {
                    error = "You were not attending this event.",
                };
                return(new ObjectResult(res));
            }
        }
        public void EventRepo_CalculateByType_ShouldBeCorrect()
        {
            EventRepo eventRepo = new EventRepo();

            Event cost = new Event();

            cost.PerOutCost = 5m;
            cost.OutType    = OutType.APark;
            Event outing = new Event();

            outing.PerOutCost = 5m;
            outing.OutType    = OutType.APark;
            Event outingTwo = new Event();

            outingTwo.PerOutCost = 5m;

            eventRepo.AddEventToList(cost);
            eventRepo.AddEventToList(outing);
            eventRepo.AddEventToList(outingTwo);

            decimal actual   = eventRepo.CalculateByType(OutType.APark);
            decimal expected = 10m;

            Assert.AreEqual(expected, actual);
        }
Esempio n. 12
0
        public IActionResult Delete(int EventID)
        {
            try
            {
                EventRepo e = new EventRepo(_context);
                e.Delete(EventID);
                var res = new
                {
                    StatusCode = "ok",
                    message    = "Deleted"
                };

                return(new ObjectResult(res));
            }
            catch
            {
                var errorRes = new
                {
                    StatusCode = "error",
                    message    = "You can't delete an event with attendees."
                };

                return(new ObjectResult(errorRes));
            }
        }
        public IActionResult leaveEvent(int eventID)
        {
            MemberRepo memRP   = new MemberRepo(_context);
            EventRepo  eventRP = new EventRepo(_context);
            var        claim   = HttpContext.User.Claims.ElementAt(0);
            string     email   = claim.Value;
            var        member  = memRP.GetOneByEmail(email);

            try
            {
                eventRP.leaveEvent(eventID, member.Id);

                var responseObject = new
                {
                    StatusCode = "removed from guest list",
                };
                return(new ObjectResult(responseObject));
            }
            catch
            {
                var responseObject = new
                {
                    error = "Error",
                };
                return(new ObjectResult(responseObject));
            }
        }
Esempio n. 14
0
        public ActionResult Create()
        {
            ViewBag.EventCode  = new SelectList(EventRepo.Get(), "id", "Code");
            ViewBag.DesignCode = new SelectList(DesignRequestRepo.Get(), "id", "Code");
            PromotionViewModel model = new PromotionViewModel();

            return(PartialView("_Create", model));
        }
Esempio n. 15
0
 public EventController(UserManager <ApplicationUser> userManager,
                        ApplicationDbContext context,
                        ILogger <EventRepo> logger)
 {
     _userManager  = userManager;
     _eventRepo    = new EventRepo(context, logger);
     _attendeeRepo = new AttendeeRepo(context, logger);
 }
Esempio n. 16
0
        public UnitOfWork(CPContext context)
        {
            _context = context;

            Customers = new CustomerRepo(_context);
            Events    = new EventRepo(_context);
            Locations = new LocationRepo(_context);
        }
        public BookingEvent GetBookingEventById(long id)
        {
            BookingEvent e = EventRepo.Query(a => a.Id == id).FirstOrDefault();

            EventRepo.LoadIfNot(e.Schedules);

            return(e);
        }
Esempio n. 18
0
        private bool SeedUser()
        {
            EventRepo eventRepo = new EventRepo();
            //eventRepo.
            DateTime dateTime = DateTime.Parse("10/31/2020");

            return(eventRepo.AddEvent(Events.AmusementPark, 50, dateTime, 1000.00m));
        }
Esempio n. 19
0
        public void ClearEventsTrue()
        {
            EventRepo eventRepo    = new EventRepo();
            int       initialCount = eventRepo.GetEvents().Count;
            DateTime  dateTime     = DateTime.Parse("10/31/2020");

            eventRepo.AddEvent(Events.AmusementPark, 50, dateTime, 12250.50m);
            Assert.IsTrue(eventRepo.ClearEvents());
        }
Esempio n. 20
0
        //Get Create 3
        public ActionResult Create3(int eventid)
        {
            UserViewModel model2 = PromotionRepo.GetIdByName(User.Identity.Name);

            ViewBag.EventCode = new SelectList(EventRepo.Get(), "id", "Code");
            PromotionViewModel model = new PromotionViewModel();

            model.RequestBy  = model2.Fullname;
            model.T_Event_Id = eventid;
            return(PartialView("_Create3", model));
        }
Esempio n. 21
0
        public IActionResult GetOne(int EventID)
        {
            EventRepo e     = new EventRepo(_context);
            var       query = e.GetOne(EventID);
            var       res   = new
            {
                EventArray = query
            };

            return(new ObjectResult(res));
        }
Esempio n. 22
0
        public async Task <IActionResult> OnGetAsync()
        {
            EventRepo e     = new EventRepo(_context);
            var       query = e.GetAll();
            var       res   = new
            {
                EventArray = query
            };

            return(new ObjectResult(res));
        }
Esempio n. 23
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetButtonDown("Restart"))
     {
         var sceneName = SceneManager.GetActiveScene().name;
         SceneManager.UnloadSceneAsync(sceneName);
         EventRepo.DeregisterAll();
         SceneManager.LoadScene(sceneName);
         GameStateData.GameOver = false;
     }
 }
        public IActionResult GetEvent(int eventID)
        {
            EventRepo eventRP   = new EventRepo(_context);
            var       query     = eventRP.GetEvent(eventID);
            var       resultObj = new
            {
                EventArray = query,
            };

            return(new ObjectResult(resultObj));
        }
Esempio n. 25
0
        public async Task ShouldReturnListingsGivenValidEventId()
        {
            //Given
            var id = 2159132;

            var sut = new EventRepo(new ViagogoApiProvider(new CredentialProvider(), "MyTestApp"));

            //When
            var results = await sut.GetEventListings(id);

            results.Should().NotBeNull();
        }
Esempio n. 26
0
        public async Task ShouldNotCallTheApiIfNullIsPassed()
        {
            //Given
            var searchTerms = default(string);
            var sut         = new EventRepo(_mockApiProvider.Object);

            //When
            await sut.GetEventDetails(searchTerms);

            //Then
            _mockApiProvider.Verify(m => m.GetViagogoApiClient(), Times.Never);
        }
Esempio n. 27
0
        public async Task ShouldCallTheApiIfSearchTermIsNotNull()
        {
            //Given
            var sut         = new EventRepo(_mockApiProvider.Object);
            var searchTerms = "stereophonics";

            //When
            await sut.GetEventDetails(searchTerms);

            //Then
            _mockApiProvider.Verify(m => m.GetViagogoApiClient(), Times.Once);
        }
Esempio n. 28
0
        public async Task ShouldReturnNullIfEventIdIsNotExisting()
        {
            //Given
            var id = Int32.MaxValue;

            var sut = new EventRepo(new ViagogoApiProvider(new CredentialProvider(), "MyTestApp"));

            //When
            var results = await sut.GetEventListings(id);

            results.Should().BeNull();
        }
Esempio n. 29
0
        public async Task ShouldReturnNullIfNoResultsFromApiCall()
        {
            //Given
            var searchTerms = $"no-results-{Guid.NewGuid()}";

            var sut = new EventRepo(_mockApiProvider.Object);

            //When
            var results = await sut.GetEventDetails(searchTerms);

            //Then
            results.Should().BeNull();
        }
Esempio n. 30
0
        public void TestMethod1()
        {
            using (var ctx = new EventMapContext())
            {
                var repo = new EventRepo(ctx);

                var findEventWithSearchModel = repo.FindEventWithSearchModel(new SearchingModel()
                {
                    Keyword = "amb"
                });
                var events = ctx.Events.ToList();
            }
        }