예제 #1
0
 private static Meetup ExecuteCommand(this Meetup @this, Action command)
 {
     @this.UpdateNumberOfSeats(SeatsNumber.From(numberOfSeats));
     @this.UpdateLocation(Address.From(address));
     @this.UpdateTime(timeRange);
     command();
     return(@this);
 }
예제 #2
0
 public MeetupRegisterModel(Meetup meetup)
 {
     Meetup = meetup;
     if (meetup != null)
     {
         MeetupId = meetup.Id;
     }
 }
예제 #3
0
 public NextMeetupView(Meetup meetup)
 {
     MeetupId    = meetup.Id;
     Title       = meetup.Title;
     MeetupDate  = $"Du {meetup.StartDate:dd/MM/yyyy} au {meetup.EndDate:dd/MM/yyyy}";
     CanRegister = meetup.IsVisible && meetup.OpenForRegistrationOn.HasValue &&
                   meetup.OpenForRegistrationOn.Value <= DateTime.Now.Date;
 }
예제 #4
0
 private TemplateModel CreateTemplateModel(Meetup meetup)
 {
     var agendaItems = meetup.Sessions.Select(s => new TemplateModel.TemplateAgendaItem
     {
         StartTime = $"{s.StartTime:HH:mm}",
         EndTime   = $"{s.EndTime:HH:mm}",
         Speakers  = string.Join(", ", s.Talk.Speakers.Select(sp => $"{sp.Speaker.Name} ({sp.Speaker.CompanyName})")),
         TalkTitle = $"«{s.Talk.Title}»"
     }).ToList();
예제 #5
0
 private bool MeetupIsValid(Meetup meetup)
 {
     if (meetup.IsValid())
     {
         return(true);
     }
     NotificarValidacoesErro(meetup.ValidationResult);
     return(false);
 }
예제 #6
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Meetup meetup = await db.Meetups.FindAsync(id);

            db.Meetups.Remove(meetup);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
예제 #7
0
        public async Task <Meetup> CreateMeetup([FromBody] MeetupModel model)
        {
            var meetup = new Meetup(model.Description);

            _dbContext.Meetups.Add(meetup);
            await _dbContext.SaveChangesAsync();

            return(meetup);
        }
예제 #8
0
 private void MapPropsToRecord(Meetup record, MeetupRequest request)
 {
     record.Name              = request.Name;
     record.Date              = request.Date;
     record.Organizer         = request.Organizer;
     record.IsPrivate         = request.IsPrivate;
     record.Location.City     = request.City;
     record.Location.Street   = request.Street;
     record.Location.PostCode = request.PostalCode;
 }
예제 #9
0
 public void DeleteMeetup(Meetup meetup)
 {
     try
     {
         Meetup.Delete(meetup);
     }
     catch
     {
     }
 }
예제 #10
0
        public async Task Map_Should_Return_Null_If_Meetup_Is_Null()
        {
            MeetupModelMapperMock mock = MeetupModelMapperMock.Create();

            Meetup meetup = null;

            MeetupModel meetupModel = await mock.Map(meetup);

            Assert.Null(meetupModel);
        }
예제 #11
0
        public void Handle(string name, string description, string scheduledFor)
        {
            Guid id = Guid.NewGuid();

            meetupRepository.Add(Meetup.Schedule(id,
                                                 Name.FromString(name),
                                                 Description.FromString(description),
                                                 DateTimeOffset.Parse(scheduledFor)));
            created(id);
        }
예제 #12
0
        public async Task <IActionResult> CreateMeetupAsync([FromBody] Meetup meetup)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await _mediator.Send(new CreateMeetupCommand(meetup));

            return(NoContent());
        }
        public async Task <string> Handle(CreateMeetupCommand request, CancellationToken cancellationToken)
        {
            var location = new Location(request.Address);
            var meetup   = new Meetup(_identityService.GetUserId(), request.Subject, request.When, request.Description, location, _meetupPolicy);

            await _meetupRepository.AddAsync(meetup);

            await _meetupRepository.UnitOfWork.SaveEntitiesAsync();

            return(meetup.Id);
        }
        public async Task <IActionResult> Create([Bind("Id,EventTitle,Venue,Date,StartTime,EndTime")] Meetup meetup)
        {
            if (ModelState.IsValid)
            {
                _context.Add(meetup);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(meetup));
        }
예제 #15
0
        public void MeetupCreateTest()
        {
            var title    = Auto.Create <MeetupTitle>();
            var location = Auto.Create <Location>();

            var meetup = new Meetup(title, location);

            Assert.Equal(title, meetup.Title);
            Assert.Equal(location, meetup.Location);
            Assert.Equal(MeetupState.Created, meetup.State);
        }
예제 #16
0
        private AdminMeetupModel GetMeetupDetailModel(Meetup meetup, IMapper mapper)
        {
            AdminMeetupModel      model    = mapper.Map <AdminMeetupModel>(meetup);
            List <CharterContent> charters = Domain.GetCharterFor(meetup.Id, true, false, true).ToList();

            charters.Add(new CharterContent {
                Position = charters.Count() + 1, MeetupId = meetup.Id
            });
            model.Contents = charters;
            return(model);
        }
예제 #17
0
        public async Task <IHttpActionResult> GetMeetup(int id)
        {
            Meetup meetup = await db.Meetups.FindAsync(id);

            if (meetup == null)
            {
                return(NotFound());
            }

            return(Ok(meetup));
        }
예제 #18
0
        public void ValidateIsMeetInOfficeHours()
        {
            Meetup newMeet = new Meetup {
                MeetupStart = new DateTime(2011, 03, 21, 16, 00, 0), MeetupEnd = new DateTime(2011, 03, 21, 17, 0, 0), EntityName = "EMP001"
            };
            OfficeHours offHours = new OfficeHours {
                StartTime = new TimeSpan(9, 0, 0), EndTime = new TimeSpan(17, 30, 0)
            };

            Assert.Equal(_planMeetup.ValidateOfficeTimeLimits(newMeet, offHours), true);
        }
예제 #19
0
        public IActionResult PostRegister(MeetupRegisterModel model, [FromServices] IConfiguration configuration)
        {
            if (ModelState.IsValid)
            {
                var          accomodations = AccomodationModel.DefaultAccomodationModels;
                Registration r             = new Registration(CurrentUser.Id, model.MeetupId)
                {
                    AccomodationId     = model.AccomodationId,
                    Notes              = model.Notes,
                    NumberOfAdults     = model.AdultNumber,
                    NumberOfChildren   = model.ChildrenNumber,
                    RegistrationStatus = ERegistrationStatus.Registered
                };
                Domain.AddOrUpdateRegistration(r);
                string body = "Bonjour :-) <br/><br/>";
                body += "Voici une réservation à partir du site de Rencontres Non-Scos :<br/><br/>";
                body += $"Prénom : {CurrentUser.FirstName}<br/>  Nom : {CurrentUser.LastName} <br/>Email : {CurrentUser.Email}<br/>";
                body +=
                    $"Logement : {accomodations.Single(x => x.Id == r.AccomodationId).Id}<br/>Adultes : {r.NumberOfAdults} <br/>Enfants : {r.NumberOfChildren}<br/>";
                if (!string.IsNullOrWhiteSpace(r.Notes))
                {
                    body += "Notes :<hr>";
                    body += r.Notes;
                    body += "<hr>";
                }

                body += "<br/>Cordialement";
                SendEmail     se    = new SendEmail();
                Meetup        m     = Domain.GetMeetup(model.MeetupId, true);
                MyMeetupEmail email = new MyMeetupEmail($"{CurrentUser.FirstName} {CurrentUser.LastName} s'inscrit à " + m.Title, body, m.MeetupPlaceAdminEmail ?? configuration["emailContact"],
                                                        configuration["emailContact"]);
                if (!string.IsNullOrEmpty(m.MeetupPlaceAdminEmail))
                {
                    email.BCC = configuration["emailContact"];
                }

                if (Debugger.IsAttached)
                {
                    email.To      = configuration["emailContact"];
                    email.Subject = "TEST " + email.Subject;
                }

                email.ReplyTo = CurrentUser.Email;
                email.CC      = CurrentUser.Email;
                SendEmail s = new SendEmail();
                se.SendSmtpEmail(EmailSender.GetSettings(configuration), email);
                return(Redirect("/me"));
            }
            MeetupRegisterModel rm = CreateModelForRegistration(model);

            Tools.TransferModalStateError(rm.Errors, ModelState);

            return(View("Register", rm));
        }
예제 #20
0
        public async Task <IHttpActionResult> PostMeetup(Meetup meetup)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Meetups.Add(meetup);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = meetup.Id }, meetup));
        }
예제 #21
0
        public async Task <IActionResult> Create([Bind("Id,Name,Description,TechId")] Meetup meetup)
        {
            if (ModelState.IsValid)
            {
                _context.Add(meetup);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TechId"] = new SelectList(_context.Tech, "Id", "Name", meetup.TechId);
            return(View(meetup));
        }
예제 #22
0
        public static MeetupAdminShortModel FromMeetup(Meetup meetup)
        {
            MeetupAdminShortModel m = new MeetupAdminShortModel
            {
                MeetupId              = meetup.Id,
                IsVisible             = meetup.IsVisible,
                OpenForRegistrationOn = meetup.OpenForRegistrationOn?.ToString("dd MMM yyyy") ?? string.Empty,
                Title = meetup.Title
            };

            return(m);
        }
        private GetMeetupQueryItem MapMeetup(Meetup meetup)
        {
            var meetupDetail = new GetMeetupQueryItem
            {
                Address     = meetup.Location.Address,
                Description = meetup.Description,
                Subject     = meetup.Subject,
                When        = meetup.When
            };

            return(meetupDetail);
        }
예제 #24
0
        public async Task <IHttpActionResult> GetMeetup(int id)
        {
            Meetup meetup = await db.Meetups
                            .Where(m => m.IsCancelled == false)
                            .FirstOrDefaultAsync(x => x.Id == id);

            if (meetup == null)
            {
                return(NotFound());
            }
            return(Ok(meetup));
        }
예제 #25
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,Title,Description,When,Where,Sponsor")] Meetup meetup)
        {
            if (ModelState.IsValid)
            {
                db.Entry(meetup).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            //ViewBag.Sponsor = new SelectList(db.ApplicationUsers, "Id", "Email", meetup.Sponsor);
            return(View(meetup));
        }
예제 #26
0
        public void Should_Succes_When_CreatingMeetup()
        {
            var meetup = new Meetup(
                organizerId: "123",
                subject: "DDD",
                when: DateTime.Now.AddDays(1),
                description: "DDD Practices",
                location: new Location("YTÜ Teknopark"),
                policy: meetupPolicy);

            Assert.NotNull(meetup);
        }
예제 #27
0
        public void Should_RaiseDomainEvent_When_MeetupCreated()
        {
            var meetup = new Meetup(
                organizerId: "123",
                subject: "DDD",
                when: DateTime.Now.AddDays(1),
                description: "DDD Practices",
                location: new Location("YTÜ Teknopark"),
                policy: meetupPolicy);

            Assert.Single(meetup.DomainEvents);
        }
예제 #28
0
        public void ValidateAppliedMeetups()
        {
            string   input = "2011-03-17 10:17:06 EMP001 2011-03-21 09:00 3";
            DateTime bookingDate;
            Meetup   meet    = _planMeetup.GetAppliedMeetups(input, out bookingDate);
            Meetup   meetExp = new Meetup {
                MeetupStart = new DateTime(2011, 03, 21, 09, 00, 0), MeetupEnd = new DateTime(2011, 03, 21, 12, 0, 0), EntityName = "EMP001"
            };
            var obj1Str = JsonConvert.SerializeObject(meet);
            var obj2Str = JsonConvert.SerializeObject(meetExp);

            Assert.Equal(obj1Str, obj2Str);
        }
예제 #29
0
        async void OnListViewItemTapped(object sender, ItemTappedEventArgs e)
        {
            Meetup tappedItem = e.Item as Meetup;

            try
            {
                await Navigation.PushAsync(new Detalhes(tappedItem));
            }
            catch (Exception ex)
            {
                await DisplayAlert("Ops!", ex.Message, "OK");
            }
        }
        public void SignUp(uint meetup, User user)
        {
            if (meetup != 0)
            {
                if (user != null)
                {
                    mUp = new MeetupData().Get(meetup);
                    var ok = true;

                    if (mUp.Date > DateTime.Now)
                    {
                        if (mUp.Date < DateTime.Today.AddDays(10) ||
                            (mUp.Date < DateTime.Today.AddDays(30) && user.Plan == MembershipPlan.Silver) ||
                            user.Plan == MembershipPlan.Gold
                            )
                        {
                            var meetupLocation = new LocationData().GetLocation(meetup);
                            int travelDistance = new LocationData().FindDistance(user.LocationId, meetupLocation);

                            new MeetupData().AddParticipant(meetup, user.Id, travelDistance);
                        }
                        else if (mUp.Date > DateTime.Today.AddDays(10))
                        {
                            if (user.Plan == MembershipPlan.Free)
                            {
                                throw new Exception("You can sign up for meetups only in the last 10 days before start. Upgrade otherwise.");
                            }
                        }
                        else if (mUp.Date > DateTime.Today.AddDays(30))
                        {
                            if (user.Plan == MembershipPlan.Silver)
                            {
                                throw new Exception("You can sign up for meetups only in the last 30 days before start. Upgrade otherwise.");
                            }
                        }
                    }
                    else
                    {
                        throw new Exception("Past meetup.");
                    }
                }
                else
                {
                    throw new ArgumentNullException("user");
                }
            }
            else
            {
                throw new ArgumentException("Meetup is required.");
            }
        }
예제 #31
0
 public static void GetEvents(Meetup meetup)
 {
     foreach (Group group in meetup.Groups)
     {
         string url = string.Format("https://api.meetup.com/2/events?group_id={0}&page=20&access_token={1}", group.Id, meetup.AccessToken);
         string response = GetResponse(url);
         try
         {
             JavaScriptSerializer serializer = new JavaScriptSerializer();
             Dictionary<string, object> dict = serializer.Deserialize<Dictionary<string, object>>(response);
             IEnumerable events = dict["results"] as IEnumerable;
             foreach (dynamic evt in events)
             {
                 MeetupEvent me = new MeetupEvent();
                 meetup.MeetupEvents.Add(me);
                 me.Id = evt["id"].ToString();
                 me.Name = evt["name"].ToString();
             }
         }
         catch { }
     }
 }
예제 #32
0
 public string Finds_third_day_of_week_in_a_month(int month, DayOfWeek dayOfWeek)
 {
     DateTime day = new Meetup(month, 2013).Day(dayOfWeek, Schedule.Third);
     return day.ToString("yyyy-M-d");
 }
예제 #33
0
 public string Finds_first_teenth_day_of_week_in_a_month(int month, DayOfWeek dayOfWeek)
 {
     var day = new Meetup(month, 2013).Day(dayOfWeek, Schedule.Teenth);
     return day.ToString("yyyy-M-d");
 }
예제 #34
0
 public static void GetGroups(Meetup meetup)
 {
     string url = string.Format("https://api.meetup.com/2/groups?organizer_id={0}&page=20&access_token={1}", "8157820", meetup.AccessToken);
     string response = GetResponse(url);
     try
     {
         JavaScriptSerializer serializer = new JavaScriptSerializer();
         Dictionary<string, object> dict = serializer.Deserialize<Dictionary<string, object>>(response);
         IEnumerable groups = dict["results"] as IEnumerable;
         foreach (dynamic group in groups)
         {
             Group g = new Group();
             meetup.Groups.Add(g);
             g.Id = group["id"].ToString();
             g.Name = group["name"].ToString();
         }
     }
     catch { }
 }
예제 #35
0
 public static void GetMember(Meetup meetup)
 {
     string url = string.Format("https://api.meetup.com/2/member/self/?access_token={0}", meetup.AccessToken);
     string response = GetResponse(url);
     try
     {
         Dictionary<string, object> dict = new JavaScriptSerializer().Deserialize<Dictionary<string, object>>(response);
         meetup.Member.Id = dict["id"].ToString();
         meetup.Member.Name = dict["name"].ToString();
     }
     catch { }
 }