Ejemplo n.º 1
0
 public void GiveKudos(User user)
 {
     if (user != null && !Kudos.Contains(user.Id))
     {
         RaiseEvent(new KudosGiven(Id, UserId, user.Id, Kudos.Count + 1));
     }
 }
Ejemplo n.º 2
0
        public IActionResult Post([FromBody] Kudos kudos)
        {
            db.InsertRecord("Kudos", kudos);

            UpdateKudos(kudos.Destino, "add");

            return(Ok(kudos));
        }
Ejemplo n.º 3
0
        public IActionResult Delete(string id, [FromBody] Kudos kudos)
        {
            db.DeleteRecord <Kudos>("Kudos", ObjectId.Parse(id));

            UpdateKudos(kudos.Destino, "dec");

            return(Ok());
        }
Ejemplo n.º 4
0
        private async Task LoadActivityDetails(string activityId)
        {
            Kudos.Clear();
            Comments.Clear();
            RelatedAthletes.Clear();

            var activity = await _stravaService.GetActivityAsync(activityId, true);

            var athlete = await _stravaService.GetAthleteAsync();

            if (activity != null)
            {
                SelectedActivity = activity;

                if (activity.KudosCount > 0 && activity.Kudos != null && activity.Kudos.Any())
                {
                    foreach (AthleteSummary kudo in activity.Kudos)
                    {
                        Kudos.Add(kudo);
                    }
                }

                if (activity.CommentCount > 0 && activity.Comments != null && activity.Comments.Any())
                {
                    foreach (Comment comment in activity.Comments)
                    {
                        Comments.Add(comment);
                    }
                }

                if (activity.OtherAthleteCount > 0 && activity.RelatedActivities != null && activity.RelatedActivities.Any())
                {
                    foreach (ActivitySummary relatedActivity in activity.RelatedActivities)
                    {
                        RelatedAthletes.Add(relatedActivity.Athlete);
                    }
                }

                //Currently the Public API of Strava will not give us Segments info for 'other' athletes then the one logged in
                HasSegments = SelectedActivity.SegmentEfforts != null;

                //Currently the Public API of Strava will not give us the Photo links for 'other' athletes then the one logged in
                //But we do get the photo count, so we also need to verify the current user vs the one from the activity
                HasPhotos = athlete.Id == SelectedActivity.Athlete.Id && SelectedActivity.TotalPhotoCount > 0;
                HasKudoed = athlete.Id == SelectedActivity.Athlete.Id || SelectedActivity.HasKudoed;

                //TODO: Glenn - Why oh why are we not yet able to show/hide PivotItems through Visibility bindable
                ServiceLocator.Current.GetInstance <IMessenger>().Send <PivotMessage>(new PivotMessage(Pivots.Segments, HasSegments));
                ServiceLocator.Current.GetInstance <IMessenger>().Send <PivotMessage>(new PivotMessage(Pivots.Photos, HasPhotos));

                ServiceLocator.Current.GetInstance <IMessenger>()
                .Send <ActivityPolylineMessage>(!string.IsNullOrEmpty(activity?.Map.SummaryPolyline)
                        ? new ActivityPolylineMessage(activity.Map.GeoPositions)
                        : new ActivityPolylineMessage(new List <BasicGeoposition>()));
            }
        }
Ejemplo n.º 5
0
        public bool AddKudos(Kudos kudos, Donator donator, Recipient recipient)
        {
            kudos.Donator   = donator;
            kudos.Recipient = recipient;

            _kudosRepository.SaveKudos(kudos);
            _sendNotificationsService.BroadcastAssigningKudos(recipient.Name, kudos.ForWhat, donator.Name);

            return(true);
        }
Ejemplo n.º 6
0
        private void CreateKudos(Kudos kudos)
        {
            var client  = new RestClient("http://localhost:61798/api/kudos");
            var request = new RestRequest(Method.POST);

            string json = "{\"fuente\":\"" + kudos.Fuente + "\", \"destino\":\"" + "" + kudos.Destino + "\",\"tema\":\"" + kudos.Tema + "\",\"fecha\":\"" + kudos.Fecha + "\",\"lugar\":\"" + kudos.Lugar + "\",\"texto\":\"" + kudos.Texto + "\"}";

            request.AddHeader("Content-Type", "application/json");
            request.AddParameter("application/json", json, ParameterType.RequestBody);
            var response = client.Execute(request);
        }
Ejemplo n.º 7
0
        public ActionResult Create(Kudos kudos, string fuente, string destino)
        {
            kudos.Fecha = DateTime.Now.ToShortDateString();

            var users = GetUsers();

            ViewBag.Users = users;

            if (ModelState.IsValid)
            {
                CreateKudos(kudos);

                return(RedirectToAction("Index"));
            }

            return(View("Create", kudos));
        }
Ejemplo n.º 8
0
        public bool SaveKudos(Kudos kudos)
        {
            try
            {
                _context.Add(new EkudosModel()
                {
                    Id      = Guid.NewGuid(),
                    Who     = kudos.Recipient.Name,
                    Donator = kudos.Donator.Name,
                    ForWhat = kudos.ForWhat,
                    When    = kudos.When,
                    Giphy   = kudos.Giphy
                });
                _context.SaveChanges();

                return(true);
            }
            catch
            {
                // TODO to add logging errors
                return(false);
            }
        }
Ejemplo n.º 9
0
        private async Task LoadActivityDetails(string activityId)
        {
            //We need to unload (remove the PropertyChanged event handler) from the
            //UserMeasurementUnitStatisticsDetail items to avoid memory leaks
            //Not prety, but I don't see a better solution atm
            //ToDo: maybe use CleanUp in order to unwire eventhandlers?
            SelectedActivity?.Statistics?.Where(a => a is UserMeasurementUnitStatisticsDetail)
            .Select(a => a as UserMeasurementUnitStatisticsDetail).ToList().ForEach(a => a.Unload());

            Kudos.Clear();
            Comments.Clear();
            RelatedAthletes.Clear();

            //TODO: Glenn - Why aren't we receiving private activities?
            Activity activity = null;

            try
            {
                activity = await _stravaService.GetActivityAsync(activityId, true);
            }
            catch (Exception ex)
            {
                var t = ex.Message;
            }
            _athlete = await _stravaService.GetAthleteAsync();

            if (activity != null)
            {
                SelectedActivity = activity;

                if (activity.KudosCount > 0 && activity.Kudos != null && activity.Kudos.Any())
                {
                    foreach (AthleteSummary kudo in activity.Kudos)
                    {
                        Kudos.Add(kudo);
                    }
                }

                if (activity.CommentCount > 0 && activity.Comments != null && activity.Comments.Any())
                {
                    foreach (Comment comment in activity.Comments)
                    {
                        Comments.Add(comment);
                    }
                }

                if (activity.OtherAthleteCount > 0 && activity.RelatedActivities != null && activity.RelatedActivities.Any())
                {
                    foreach (ActivitySummary relatedActivity in activity.RelatedActivities)
                    {
                        RelatedAthletes.Add(relatedActivity.Athlete);
                    }
                }

                //Currently the Public API of Strava will not give us Segments info for 'other' athletes then the one logged in
                HasSegments = SelectedActivity.SegmentEfforts != null;

                //Currently the Public API of Strava will not give us the Photo links for 'other' athletes then the one logged in
                //But we do get the photo count, so we also need to verify the current user vs the one from the activity
                HasPhotos     = _athlete.Id == SelectedActivity.Athlete.Id && SelectedActivity.TotalPhotoCount > 0;
                HasKudoed     = _athlete.Id == SelectedActivity.Athlete.Id || SelectedActivity.HasKudoed;
                IsEditEnabled = _athlete.Id == SelectedActivity.Athlete.Id;

                //TODO: Glenn - Why oh why are we not yet able to show/hide PivotItems through Visibility binding
                ServiceLocator.Current.GetInstance <IMessenger>().Send <PivotMessage <ActivityPivots> >(new PivotMessage <ActivityPivots>(ActivityPivots.Segments, HasSegments), Tokens.ActivityPivotMessage);
                ServiceLocator.Current.GetInstance <IMessenger>().Send <PivotMessage <ActivityPivots> >(new PivotMessage <ActivityPivots>(ActivityPivots.Photos, HasPhotos), Tokens.ActivityPivotMessage);

                ServiceLocator.Current.GetInstance <IMessenger>()
                .Send <PolylineMessage>(!string.IsNullOrEmpty(activity?.Map.SummaryPolyline)
                        ? new PolylineMessage(activity.Map.GeoPositions)
                        : new PolylineMessage(new List <BasicGeoposition>()), Tokens.ActivityPolylineMessage);
            }
        }
Ejemplo n.º 10
0
 public void Apply(KudosGiven @event)
 {
     Kudos.Add(@event.UserId);
 }