Esempio n. 1
0
        public void Save_event_to_store()
        {
            var tabOpened = GenerateTabOpened();

            _storeRepository.Add(tabOpened);

            var events = DbContext.Events.Count(ev => ev.AggregateId == _aggregateId);

            Assert.That(events, Is.EqualTo(1));
        }
Esempio n. 2
0
        public async Task <ActionResult> CreateAsync(ViewModels.Event.CreateViewModel model)
        {
            try
            {
                if (model.Date < DateTime.Now)
                {
                    return(BadRequest("La fecha del evento no debe ser menor al día de hoy"));
                }

                var geometryFactory = NtsGeometryServices.Instance.CreateGeometryFactory(srid: 4326);

                Event newEvent = new Event
                {
                    Title         = model.Title,
                    Description   = model.Description,
                    Date          = model.Date,
                    Image         = model.Image,
                    Attendances   = model.Attendances,
                    WillYouAttend = model.WillYouAttend,
                    Location      = geometryFactory.CreatePoint(new Coordinate(double.Parse(model.Location[1].ToString()), double.Parse(model.Location[0].ToString())))
                };

                await _repository.Add(newEvent);

                return(Ok(newEvent.Id));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex));
            }
        }
Esempio n. 3
0
        public async Task <bool> Add(int personId, Event newEvent)
        {
            if (newEvent.Place != null)
            {
                newEvent.PlaceId = newEvent.Place.Id;
            }
            newEvent.Place = null;

            if (newEvent.Id == 0)
            {
                _eventRepository.Add(newEvent);
            }

            var newPersonEvent = new PersonEvent
            {
                PersonId = personId,
                Event    = newEvent
            };

            var person = _personRepository
                         .GetAll()
                         .Include(e => e.PersonEvents)
                         .FirstOrDefault(p => p.Id == personId);

            person.PersonEvents.Add(newPersonEvent);

            return(await _eventRepository.SaveChangesAsync());
        }
Esempio n. 4
0
 public EventDto Add(EventDto entity)
 {
     using (var repo = new EventRepository())
     {
         return(repo.Add(entity));
     }
 }
Esempio n. 5
0
        public void CreateANewEventStoreItAndRecoverIt()
        {
            var path     = Path.Combine(Directory.GetCurrentDirectory(), "");
            var newEvent = new Cevent()
            {
                Adress           = "8 allée émile roux. 77700 CHAMPS SUR MARNE",
                Title            = "House of disciple",
                AdressComplement = "Pour y accéder passer devant la maison de JUDE",
                ChurchLink       = "http://eglise.champs-sur-marne.com",
                Description      = "Cette maison sert l'éternel ^^",
                KeyWord          = "Jésus;Maison de Dieu;",
                StartOfEvent     = new DateTime(2016, 12, 24),
                EndOfEvent       = new DateTime(2016, 12, 30),
                CreatedOn        = new DateTime(2016, 12, 5),
                ModifiedOn       = DateTime.Now,
                Price            = 0,
                Owner            = 1,
                YoutubeLink      = "http://youtube.com",
                Id = 1
            };

            newEvent.SetGpsPosition(2, 2.9f);
            newEvent.Save();
            var repo = new EventRepository(path);

            repo.Add(newEvent);

            repo     = new EventRepository(path);
            newEvent = repo.Get(1);
            Assert.NotNull(newEvent);
            Assert.AreEqual(newEvent.Owner, 1);
            Assert.AreEqual(newEvent.GetGpsPosition(), new GpsPosition(2, 2.9f));
        }
Esempio n. 6
0
        public int Add(ManageEventModel model)
        {
            using (var scope = new TransactionScope())
            {
                try
                {
                    model.Image = Cdn.Base64ToImageUrl(model.Image);
                    var eventId = _event.Add(new EventModel()
                    {
                        Image        = model.Image,
                        Title        = model.Title,
                        Message      = model.Message,
                        CreatedBy    = model.UserId,
                        DateTime     = model.DateTime,
                        EntityId     = model.EntityId,
                        EntityTypeId = model.EntityTypeId,
                        OccationId   = model.OccationId
                    });

                    // Adding Users
                    foreach (var user in model.Users)
                    {
                        _eventUser.Add(new EventUserModel()
                        {
                            UserId    = user.UserId,
                            CreatedBy = model.UserId,
                            EventId   = eventId
                        });
                    }

                    // Adding Groups
                    foreach (var group in model.Groups)
                    {
                        _eventGroup.Add(new EventGroupModel()
                        {
                            GroupId   = group,
                            CreatedBy = model.UserId,
                            EventId   = eventId
                        });
                    }

                    scope.Complete();

                    return(eventId);
                }
                catch (Exception ex)
                {
                    scope.Dispose();
                    JavaScriptSerializer js = new JavaScriptSerializer();
                    string json             = js.Serialize(model);
                    Log.Error("BL-Group - Add" + json, ex);
                    throw new ReturnExceptionModel(new CustomExceptionModel()
                    {
                        StatusCode = HttpStatusCode.BadRequest, Message = ex.Message
                    });
                }
            }
        }
Esempio n. 7
0
        public void Test_AddDublicate()
        {
            var data        = _fixture.CreateMany <byte>().ToArray();
            var partitionId = _fixture.Create <int>();

            _events.Add(partitionId, TestConstants.TestAdminUserId, EventType.ApplicationCreated, EventState.Emailing, data);
            _events.Add(partitionId, TestConstants.TestAdminUserId, EventType.ApplicationCreated, EventState.Emailing, data);

            using (var connection = new SqlConnection(Settings.Default.MainConnectionString))
            {
                var count =
                    connection.Query <int>(
                        "select count(1) from [dbo].[Event] where [PartitionId] = @partitionId AND [EventTypeId] = @Type",
                        new { partitionId, Type = EventType.ApplicationCreated }).First();

                count.ShouldBeEquivalentTo(2);
            }

            _events.Add(
                partitionId,
                TestConstants.TestAdminUserId,
                EventType.CPFileUploaded,
                EventState.Emailing,
                _serializer.Serialize(_fixture.Create <FileHolder>()));

            using (var connection = new SqlConnection(Settings.Default.MainConnectionString))
            {
                var count = connection.Query <int>(
                    "select count(1) from [dbo].[Event] where [PartitionId] = @partitionId",
                    new { partitionId, Type = EventType.ApplicationCreated }).First();

                count.ShouldBeEquivalentTo(3);
            }
        }
Esempio n. 8
0
        public void GivenTheseEvents(params Event[] events)
        {
            foreach (Event evnt in events)
            {
                repo.Add(evnt);
            }

            Assert.AreEqual(events.Length, repo.GetCount());
        }
Esempio n. 9
0
        public void SaveEvent()
        {
            var eventRepository = new EventRepository();

            eventRepository.Add(new AAEvent
            {
                A = 100,
                B = 1000
            });
        }
Esempio n. 10
0
        public void CreateEvent(EventDTO Event, string currentUser)
        {
            Event dbEvent = new Event()
            {
                Id       = Event.Id,
                Name     = Event.Name,
                Status   = Event.Status,
                ImageUrl = _catRepo.GetCategoryImageUrlById(Event.Category.Id).First(),
                //Feedback = Event.Feedback,
                EndTime        = Event.EndTime,
                Description    = Event.Description,
                DateOfEvent    = Event.DateOfEvent,
                DateCreated    = Event.DateCreated,
                Location       = Event.Location,
                CategoryId     = Event.Category.Id,
                AdmissionPrice = Event.AdmissionPrice,
                //Category = Event.Category,
                CreatorId = _uRepo.GetUser(currentUser).First().Id
            };


            try
            {
                //string sgUsername = "******";
                //string sgPassword = "******";


                var           user    = _uRepo.GetUser(currentUser).First();
                List <string> to      = new List <string>();
                List <string> toNames = new List <string>();

                to.Add(user.Email);
                toNames.Add(user.UserName);

                _emailService.SendMessage(to.ToArray(), toNames.ToArray(), Startup.AdminEmailAddress, "WHN Admin",
                                          Event.Name + " Created",
                                          "Your event, " + Event.Name + ", has been successfully created.\n\nBest regards,\nWHN Team");
                //var myMessage = new SendGrid();



                //var credentials = new NetworkCredential(sgUsername, sgPassword);

                //var transportWeb = new Web(credentials);

                //// Send the email.
                //transportWeb.Deliver(myMessage);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            _eventRepo.Add(dbEvent);
        }
Esempio n. 11
0
        public static void GivenTheseEvents(params Event[] events)
        {
            foreach (Event evnt in events)
            {
                // Add event to Events here.
                repo.Add(evnt);
            }

            //context.SaveChanges();
            Assert.AreEqual(events.Length, repo.GetCount());
        }
Esempio n. 12
0
        public HttpResponseMessage Post(Event item)
        {
            item.Status = EventStatus.Openning;
            item        = repository.Add(item);

            var uri      = Url.Link("DefaultApi", new { id = item.Id });
            var response = Request.CreateResponse <Event>(HttpStatusCode.Created, item);

            response.Headers.Location = new Uri(uri);
            return(response);
        }
Esempio n. 13
0
 public IActionResult Create(EventDTO obj)
 {
     if (ModelState.IsValid)
     {
         _repository.Add(_mapper.Map <Event>(obj));
         return(RedirectToAction(nameof(Index)));
     }
     else
     {
         return(View());
     }
 }
Esempio n. 14
0
        public Event InsertEventModel(EventModel eventModel, string username)
        {
            Organisation organisation = oRepository.GetOrganisationByUsername(username);

            Location location = lRepository.GetLocationByAddressCity(eventModel.Address, eventModel.City);

            if (location == null && eventModel.Latitude > 0 && eventModel.Longitude > 0)
            {
                location = new Location()
                {
                    Lat        = eventModel.Latitude,
                    Lng        = eventModel.Longitude,
                    Address    = eventModel.Address,
                    City       = eventModel.City,
                    Country    = eventModel.Country,
                    PostalCode = int.Parse(eventModel.PostalCode)
                };

                lRepository.Add(location);
                lRepository.Complete();
                location = lRepository.GetLocationByAddressCity(eventModel.Address, eventModel.City);
            }

            Event eventDB = new Event()
            {
                Name                 = eventModel.Name,
                Description          = eventModel.Description,
                IdTypeEvent          = eventModel.IdTypeEvent,
                IdOrganisation       = organisation.Id,
                NoTickets            = eventModel.NoTickets,
                MoreDayEvent         = eventModel.MoreDayEvent,
                TimeEnd              = DateTime.Parse(eventModel.TimeEnd),
                TimeStart            = DateTime.Parse(eventModel.TimeStart),
                Wifi                 = eventModel.Wifi,
                Parking              = eventModel.Parking,
                Smoking              = eventModel.Smoking,
                WebUrl               = eventModel.WebUrl,
                Phone                = eventModel.Phone,
                Email                = eventModel.Email,
                ThirdPartyTickets    = eventModel.ThirdPartyTickets,
                ThirdPartyTicketsWeb = eventModel.ThirdPartyTicketsWeb
            };

            if (location != null)
            {
                eventDB.IdLocation = location.Id;
            }

            eRepository.Add(eventDB);
            eRepository.Complete();

            return(eventDB);
        }
Esempio n. 15
0
 public async void CreateEventAsync(Event localEvent)
 {
     using (EventRepository db = GetUnit().Event)
     {
         await Task.Run(
             () =>
         {
             db.Add(localEvent);
             db.Save();
         });
     }
 }
Esempio n. 16
0
        public async Task <ActionResult> Post(
            [FromServices] EventRepository repository,
            [FromServices] DataContext context,
            [FromBody] AddEventCommand command)
        {
            try
            {
                if (ModelState.IsValid == false)
                {
                    return(BadRequest(ModelState));
                }

                var date = new DateTime(
                    Convert.ToInt32(command.Date.Substring(6, 4)),
                    Convert.ToInt32(command.Date.Substring(3, 2)),
                    Convert.ToInt32(command.Date.Substring(0, 2)),
                    0, 0, 0);

                DateTime?startH = null;
                DateTime?endH   = null;

                if (command.StartHour != "")
                {
                    startH = new DateTime(01, 01, 01, Convert.ToInt32(command.StartHour.Substring(0, 2)), Convert.ToInt32(command.StartHour.Substring(3, 2)), 0);
                }

                if (command.EndHour != "")
                {
                    endH = new DateTime(01, 01, 01, Convert.ToInt32(command.EndHour.Substring(0, 2)), Convert.ToInt32(command.EndHour.Substring(3, 2)), 0);
                }

                var @event = new Event(
                    command.Name.Trim(),
                    date,
                    startH,
                    endH,
                    command.Local.Trim(),
                    command.Note.Trim());

                repository.Add(@event);

                await context.SaveChangesAsync();

                return(Ok(new { @event }));
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  new { message = ex.Message }));
            }
        }
        public void AddEvent(params Event[] events)
        {
            foreach (Event e in events)
            {
                var tickets = e.Ticket;
                e.Ticket = new HashSet <Ticket>();
                _eventRepository.Add(events);
                List <Ticket> toAdd = new List <Ticket>(tickets);
                foreach (Ticket t in toAdd)
                {
                    t.EventId = e.Id;
                }

                _ticketRepository.Add(toAdd.ToArray());
            }
        }
Esempio n. 18
0
        private void Submit_Click(object sender, RoutedEventArgs e)
        {
            NewEventForm.Visibility = Visibility.Collapsed;
            repo = new EventRepository();
            int     odometer = Int32.Parse(Odometer.Text);
            decimal gall     = Convert.ToDecimal(Gallons.Text);
            decimal cost     = Convert.ToDecimal(CostofFillUp.Text);
            string  date     = EventDate.SelectedDate.ToString();

            repo.Add(new Event(odometer, gall, cost, date));
            FillUpList.DataContext = repo.All();
            MPG.DataContext        = repo.CalculateAverage();
            Odometer.Text          = "";
            Gallons.Text           = "";
            CostofFillUp.Text      = "";
            EventDate.Text         = "";
        }
Esempio n. 19
0
        public void Event_Dispatch_CanSendICS()
        {
            EventRepository eventRepo = new EventRepository(_uow);
            AttendeeRepository attendeesRepo = new AttendeeRepository(_uow);
            List<AttendeeDO> attendees =
                new List<AttendeeDO>
                {
                    _fixture.TestAttendee1(),
                    _fixture.TestAttendee2()
                };
            attendees.ForEach(attendeesRepo.Add);

            EventDO eventDO = new EventDO
            {
                Description = "This is my test invitation",
                Summary = @"My test invitation",
                Location = @"Some place!",
                StartDate = DateTime.Today.AddMinutes(5),
                EndDate = DateTime.Today.AddMinutes(15),
                Attendees = attendees,
                Emails = new List<EmailDO>()
            };
            eventRepo.Add(eventDO);
            Calendar.DispatchEvent(_uow, eventDO);

            //Verify success
            //use imap to load unread messages from the test customer account
            //verify that one of the messages is a proper ICS message
            //retry every 15 seconds for 1 minute

            

            //create an Email message addressed to the customer and attach the file.
            
           



            //skip for v.1: add EmailID to outbound queue



        }
        public JsonResult Save(Event raceEvent)
        {
            bool   status = false;
            string msg    = "";

            try
            {
                if (raceEvent != null)
                {
                    if (raceEvent.Id != Guid.Empty)
                    {
                        var objEvent = _eventRepository.GetById(raceEvent.Id);

                        if (objEvent != null)
                        {
                            objEvent.EventName     = raceEvent.EventName;
                            objEvent.EventDateTime = raceEvent.EventDateTime;
                            objEvent.City          = raceEvent.City;
                            status = true;
                            _eventRepository.update(objEvent);
                        }
                    }
                    else
                    {
                        _eventRepository.Add(raceEvent);
                        status = true;
                    }
                    return(new JsonResult {
                        Data = new { status = status, msg = msg }
                    });
                }
            }
            catch (Exception ex)
            {
                status = false;
                msg    = ex.Message;
            }
            return(new JsonResult {
                Data = new { status = status, msg = msg }
            });
        }
Esempio n. 21
0
        public IHttpActionResult Add([FromBody] Event @event)
        {
            var headers = Request.Headers;

            if (!headers.Contains("auth_token") && !headers.Contains("fb_auth"))
            {
                return(Ok(new { errorCode = "66", message = "unauthorized" }));
            }
            if (headers.Contains("auth_token"))
            {
                var token = headers.GetValues("auth_token").First();
                if (!_authToken.VerifyToken(token))
                {
                    return(Ok(new { errorCode = "66", message = "unauthorized" }));
                }
            }
            Event eventObj;

            _eventRepository.Add(eventObj = @event);
            return(Ok(eventObj.Id));
        }
Esempio n. 22
0
        private static void Save(IEvent ev)
        {
            if (ev == null)
            {
                throw new ArgumentNullException("ev");
            }

            var eDto = new EventDto
            {
                EventType         = ev.EventType,
                FKGalleryId       = ev.GalleryId,
                TimeStampUtc      = ev.TimestampUtc,
                ExType            = ev.ExType,
                Message           = ev.Message,
                ExSource          = ev.ExSource,
                ExTargetSite      = ev.ExTargetSite,
                ExStackTrace      = ev.ExStackTrace,
                EventData         = Serialize(ev.EventData),
                InnerExType       = ev.InnerExType,
                InnerExMessage    = ev.InnerExMessage,
                InnerExSource     = ev.InnerExSource,
                InnerExTargetSite = ev.InnerExTargetSite,
                InnerExStackTrace = ev.InnerExStackTrace,
                InnerExData       = Serialize(ev.InnerExData),
                Url              = ev.Url,
                FormVariables    = Serialize(ev.FormVariables),
                Cookies          = Serialize(ev.Cookies),
                SessionVariables = Serialize(ev.SessionVariables),
                ServerVariables  = Serialize(ev.ServerVariables)
            };

            using (var repo = new EventRepository())
            {
                repo.Add(eDto);
                repo.Save();

                ev.EventId = eDto.EventId;
            }
        }
Esempio n. 23
0
        protected void lnkAddEvent_Click(object sender, EventArgs e)
        {
            var btn = sender as LinkButton;


            Event myEvent = new Event()
            {
                Title     = txtEventTitle.Text,
                EventDate = Convert.ToDateTime(txtEventDate.Text),
                Notes     = txtEventNotes.Text,
                Completed = chkIsComplete.Checked,
                TeamId    = ddlTeam.SelectedValue.Equals(string.Empty) ? 0 : Convert.ToInt32(ddlTeam.SelectedValue)
            };

            switch (btn.CommandName)
            {
            case "New":
                evntRepo.Add(myEvent);
                break;

            case "Update":
                if (!string.IsNullOrEmpty(btn.CommandArgument))
                {
                    myEvent.EventId = Convert.ToInt32(btn.CommandArgument);
                    evntRepo.Update(myEvent);
                }


                break;

            default:
                break;
            }
            evntRepo.Save();
            LoadGrid();
        }
Esempio n. 24
0
 public void TestAddToDataBase()
 {
     Assert.AreEqual(0, repo.GetCount());
     repo.Add(new Event(200000, 10, 50, "10/1/2015"));
     Assert.AreEqual(1, repo.GetCount());
 }
 public bool AddEvent(Event evnt)
 {
     return(_eventRepository.Add(evnt));
 }
Esempio n. 26
0
 private void AddEvent_Click(object sender, RoutedEventArgs e)
 {
     NewEventForm.Visibility = Visibility.Collapsed;
     repo.Add(new Event(EventTitle.Text, EventDate.SelectedDate.ToString()));
 }
Esempio n. 27
0
 public void TestAddToDatabase() //Valid
 {
     Assert.AreEqual(0, repo.GetCount());
     repo.Add(new Event("Old Years Eve", "12/31/2015"));
     Assert.AreEqual(1, repo.GetCount());
 }
Esempio n. 28
0
 public ActionResult Post(Event value) // [FromForm]
 {
     value.CreatedTime = DateTime.UtcNow;
     eventRepository.Add(value);
     return(this.Ok("Create new event successfully"));
 }
Esempio n. 29
0
 public void AddEvent([FromBody] Event eventItem)
 {
     eventRepository.Add(eventItem);
     eventRepository.SaveChanges(eventItem);
 }
Esempio n. 30
0
        private static void Save(IEvent ev)
        {
            if (ev == null)
                throw new ArgumentNullException("ev");

            var eDto = new EventDto
            {
                EventType = ev.EventType,
                FKGalleryId = ev.GalleryId,
                TimeStampUtc = ev.TimestampUtc,
                ExType = ev.ExType,
                Message = ev.Message,
                ExSource = ev.ExSource,
                ExTargetSite = ev.ExTargetSite,
                ExStackTrace = ev.ExStackTrace,
                EventData = Serialize(ev.EventData),
                InnerExType = ev.InnerExType,
                InnerExMessage = ev.InnerExMessage,
                InnerExSource = ev.InnerExSource,
                InnerExTargetSite = ev.InnerExTargetSite,
                InnerExStackTrace = ev.InnerExStackTrace,
                InnerExData = Serialize(ev.InnerExData),
                Url = ev.Url,
                FormVariables = Serialize(ev.FormVariables),
                Cookies = Serialize(ev.Cookies),
                SessionVariables = Serialize(ev.SessionVariables),
                ServerVariables = Serialize(ev.ServerVariables)
            };

            using (var repo = new EventRepository())
            {
                repo.Add(eDto);
                repo.Save();

                ev.EventId = eDto.EventId;
            }
        }
Esempio n. 31
0
 public void Post([FromBody] Event e)
 {
     _eventRepository.Add(e);
 }