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); }
public MeetupRegisterModel(Meetup meetup) { Meetup = meetup; if (meetup != null) { MeetupId = meetup.Id; } }
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; }
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();
private bool MeetupIsValid(Meetup meetup) { if (meetup.IsValid()) { return(true); } NotificarValidacoesErro(meetup.ValidationResult); return(false); }
public async Task <ActionResult> DeleteConfirmed(int id) { Meetup meetup = await db.Meetups.FindAsync(id); db.Meetups.Remove(meetup); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <Meetup> CreateMeetup([FromBody] MeetupModel model) { var meetup = new Meetup(model.Description); _dbContext.Meetups.Add(meetup); await _dbContext.SaveChangesAsync(); return(meetup); }
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; }
public void DeleteMeetup(Meetup meetup) { try { Meetup.Delete(meetup); } catch { } }
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); }
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); }
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)); }
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); }
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); }
public async Task <IHttpActionResult> GetMeetup(int id) { Meetup meetup = await db.Meetups.FindAsync(id); if (meetup == null) { return(NotFound()); } return(Ok(meetup)); }
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); }
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)); }
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)); }
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)); }
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); }
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)); }
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)); }
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); }
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); }
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); }
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."); } }
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 { } } }
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"); }
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"); }
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 { } }
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 { } }