public ReportWindow(Land land, Earthwatcher earthwatcher)
        {
            InitializeComponent();

            commentRequests = new CommentRequests(Constants.BaseApiUrl);
            collectionRequests = new CollectionRequests(Constants.BaseApiUrl);
            landRequests = new LandRequests(Constants.BaseApiUrl);
            hexagonLayer = (HexagonLayer)Current.Instance.LayerHelper.FindLayer(Constants.Hexagonlayername);
            bcLayer = (BasecampLayer)Current.Instance.LayerHelper.FindLayer(Constants.BasecampsLayer); //TEST
            //Add event listeners
            commentRequests.CommentsByLandReceived += CommentRequestCommentsByLandReceived;
            collectionRequests.NewItemReceived += collectionRequests_NewItemReceived;
            collectionRequests.ItemsCountReceived += collectionRequests_ItemsCountReceived;
            collectionRequests.GetTotalItems(Current.Instance.Earthwatcher.Id);
            Current.Instance.MapControl.zoomFinished += MapControlZoomFinished;
            Current.Instance.MapControl.zoomStarted += MapControlZoomStarted;

            landRequests = new LandRequests(Constants.BaseApiUrl);
            landRequests.StatusChanged += SetLandStatusStatusChanged;
            landRequests.ConfirmationAdded += landRequests_ConfirmationAdded;

            hexagonLayer = (HexagonLayer)Current.Instance.LayerHelper.FindLayer(Constants.Hexagonlayername);

            this.Loaded += ReportWindow_Loaded;

            this.ShareStoryBoard.Completed += ShareStoryBoard_Completed;
        }
        public DemandWindow(Land land, Earthwatcher earthwatcher)
        {
            InitializeComponent();

            selectedLand = land;
            selectedEarthwatcher = earthwatcher;
            hexagonLayer = (HexagonLayer)Current.Instance.LayerHelper.FindLayer(Constants.Hexagonlayername);
            
            if (Current.Instance.Scores.Any(x => x.Action.Equals(ActionPoints.Action.DemandAuthorities.ToString()) && (x.LandId == selectedLand.Id)))
            {
                this.DemandIcon.Source = Earthwatchers.UI.Resources.ResourceHelper.GetBitmap("/Resources/Images/demandarShare.png");
                this.Title.Text = Labels.DemandWindow2;
                this.DemandText.Text = Labels.DemandWindow3;
                this.DemandText2.Text = Labels.DemandWindow4;
                this.DemandTitleText.Text = Labels.DemandWindow2;
            }
            else
            {
                this.DemandIcon.Source = Earthwatchers.UI.Resources.ResourceHelper.GetBitmap("/Resources/Images/demandar.png");
                this.Title.Text = Labels.DemandWindow1;
                this.DemandText.Text = Labels.DemandWindow5;
                this.DemandText2.Text = Labels.DemandWindow6;
                this.DemandTitleText.Text = Labels.DemandWindow1;
            }


        }
 public HttpResponseMessage<Earthwatcher> Post(Earthwatcher earthwatcher)
 {
     Earthwatcher earthwatcherResult = earthwatcherRepository.Post(earthwatcher);
     var response = new HttpResponseMessage<Earthwatcher>(earthwatcherResult);
     response.StatusCode = HttpStatusCode.Created;
     // todo set location in response
     //response.Headers.Location=new UriPathExtensionMapping(string.Format()
     return response;
 }
        private void EarthwatcherRequestEarthwatcherReceived(object sender, EventArgs e)
        {
            earthwatcher = sender as Earthwatcher;
            txtCountry.Text = earthwatcher.Country;
            txtName.Text = string.Format("{0} on {1}", earthwatcher.FullName, land.StatusChangedDateTime.ToShortDateString());

            if (earthwatcher == null) 
                return;

        }
        public void GenerateAndUpdatePassword(Earthwatcher earthwatcher)
        {
            var prefix = PasswordChecker.GeneratePrefix();
            var hashedPassword = PasswordChecker.GenerateHashedPassword(earthwatcher.Password, prefix);

            // store in database
            var connectionstring = System.Configuration.ConfigurationManager.ConnectionStrings["EarthwatchersConnection"].ConnectionString;
            var repos = new EarthwatcherRepository(connectionstring);
            repos.UpdatePassword(earthwatcher, prefix, hashedPassword);
        }
        public HttpResponseMessage ForgotPassword(Earthwatcher earthwatcher, HttpRequestMessage<Earthwatcher> request)
        {
            if (earthwatcher != null)
            {
                var earthwatcherDb = earthwatcherRepository.GetEarthwatcher(earthwatcher.Name, false);
                if (earthwatcherDb == null)
                {
                    var response = new HttpResponseMessage(HttpStatusCode.NotFound);
                    return response;
                }

                //Mando el mail
                try
                {
                    var dateToEncode = System.Text.Encoding.UTF8.GetBytes(DateTime.Now.ToString());
                    string encodedDate = System.Convert.ToBase64String(dateToEncode);

                    if (Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["smtp.enabled"]))
                    {
                        List<System.Net.Mail.MailMessage> messages = new List<System.Net.Mail.MailMessage>();

                        System.Net.Mail.MailAddress address = new System.Net.Mail.MailAddress(earthwatcherDb.Name);
                        System.Net.Mail.MailAddress addressFrom = new System.Net.Mail.MailAddress(System.Configuration.ConfigurationManager.AppSettings["smtp.user"], "Guardianes - Greenpeace");
                        System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
                        message.From = addressFrom;
                        message.To.Add(address);
                        message.Subject = "Reseteá tu contraseña de Guardianes - Reset your Guardians Password";

                        string domain = new Uri(HttpContext.Current.Request.Url.AbsoluteUri).GetLeftPart(UriPartial.Authority);

                        string htmlTemplate = System.IO.File.ReadAllText(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "mail.html"));
                        message.Body = string.Format(htmlTemplate, "Estimado Guardian,", "Para resetear tu contraseña hacé un click en el botón verde [Resetear Contraseña].<br><br> Por motivos de seguridad, este cambio se podrá hacer en el transcurso de las próximas 24 horas"
                            , string.Format("{0}/resetpwd.html?guid={1}&ed={2}", domain, earthwatcherDb.Guid, encodedDate), "Click aquí para resetear tu contraseña", "Resetear Contraseña", "Este mensaje se envío a", earthwatcherDb.Name
                            , ". Si no quieres recibir más notificaciones en un futuro podés acceder al Panel de Control del usuario y deshabilitar la opción de recibir notificaciones."
                            , "Greenpeace Argentina. Todos los derechos reservados.", domain);
                        message.IsBodyHtml = true;
                        message.BodyEncoding = System.Text.Encoding.UTF8;
                        message.DeliveryNotificationOptions = System.Net.Mail.DeliveryNotificationOptions.None;
                        messages.Add(message);

                        SendMails.Send(messages);
                    }
                    return new HttpResponseMessage() { StatusCode = HttpStatusCode.OK };

                }
                catch (Exception ex)
                {
                    return new HttpResponseMessage() { StatusCode = HttpStatusCode.InternalServerError, ReasonPhrase = ex.Message };
                }


            }
            return new HttpResponseMessage() { StatusCode = HttpStatusCode.BadRequest };
        }
        public static void AddLinks(Earthwatcher earthwatcher, HttpRequestMessage request)
        {
            /*
            var uriBuilder = new UriBuilder(request.RequestUri) {Path = earthwatcher.LandUri};
            earthwatcher.LandUri=uriBuilder.Uri.ToString();

            uriBuilder.Path = earthwatcher.Uri;
            earthwatcher.Uri = uriBuilder.Uri.ToString();
             * */

        }
 public HttpResponseMessage<List<string>> GetVerifiedLandsGeoHexCodes(Earthwatcher earthwatcher, HttpRequestMessage<Earthwatcher> request)
 {
     try
     {
         return new HttpResponseMessage<List<string>>(landRepository.GetVerifiedLandsGeoHexCodes(earthwatcher.Id, earthwatcher.IsPowerUser)) { StatusCode = HttpStatusCode.OK };
     }
     catch (Exception ex)
     {
         return new HttpResponseMessage<List<string>>(new List<string> { ex.Message }) { StatusCode = HttpStatusCode.InternalServerError };
     }
 }
 public void ChangePlayingRegion(Earthwatcher earthwatcher)
 {
     connection.Open();
     var cmd = connection.CreateCommand() as SqlCommand;
     cmd.CommandType = CommandType.StoredProcedure;
     cmd.CommandText = "Earthwatcher_ChangePlayingRegion";
     cmd.Parameters.Add(new SqlParameter("@playingRegion", earthwatcher.PlayingRegion));
     cmd.Parameters.Add(new SqlParameter("@playingCountry", earthwatcher.PlayingCountry));
     cmd.Parameters.Add(new SqlParameter("@id", earthwatcher.Id));
     cmd.ExecuteNonQuery();
     connection.Close();
 }
        public void ChangePlayingRegion(Earthwatcher earthwatcher)
        {
            var request = new RestRequest("earthwatchers/changeplayingregion", Method.POST) { RequestFormat = DataFormat.Json };
            request.JsonSerializer = new JsonSerializer();
            request.AddBody(earthwatcher);

            client.ExecuteAsync(request, response =>
               Deployment.Current.Dispatcher.BeginInvoke(() =>
                       PlayingRegionChanged(
                           response.StatusCode, null)
                    ));
        }
 public HttpResponseMessage ChangePlayingRegion(Earthwatcher earthwatcher, HttpRequestMessage<Earthwatcher> request)
 {
     try
     {
         earthwatcherRepository.ChangePlayingRegion(earthwatcher);
         return new HttpResponseMessage { StatusCode = HttpStatusCode.OK };
     }
     catch
     {
         return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError };
     }
 }
Exemple #12
0
 public void GetEarthwatcherShouldReturnEarthwatcher()
 {
     // arrange
     var repos = new Mock<IEarthwatcherRepository>();
     var testEarthWatcher = new Earthwatcher() { Id = 3, Name = "Bert" };
     repos.Setup(soep => soep.GetEarthwatcher("bert", false)).Returns(testEarthWatcher);
     
     // act
     var result = repos.Object.GetEarthwatcher("bert", false);
     
     // assert
     Assert.Equal(3,result.Id);
 }
        public void Confirm(int landId, int userId, ConfirmationSort confirmationSort, string username, string password)
        {
            client.Authenticator = new HttpBasicAuthenticator(username, password);

            var earthwatcher = new Earthwatcher { Id = userId };
            var request = new RestRequest("land/" + landId.ToString(CultureInfo.InvariantCulture) + @"/" + confirmationSort.ToString(), Method.PUT);
            request.AddBody(earthwatcher);
            request.RequestFormat = DataFormat.Json;
            client.ExecuteAsync(request, response =>
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    ConfirmationAdded(confirmationSort, null)
            ));
        }
 public HttpResponseMessage<Earthwatcher> ChangePasswordAdmin(Earthwatcher earthwatcher, HttpRequestMessage<Earthwatcher> request)
 {
     if (!String.IsNullOrEmpty(earthwatcher.Name) && (!String.IsNullOrEmpty(earthwatcher.Password)))
     {
             GenerateAndUpdatePassword(earthwatcher);
             var response = new HttpResponseMessage<Earthwatcher>(earthwatcher) { StatusCode = HttpStatusCode.Accepted };
             return response;
     }
     else
     {
         var response = new HttpResponseMessage<Earthwatcher>(null) { StatusCode = HttpStatusCode.BadRequest, ReasonPhrase = "request parameters not correct" };
         return response;
     }
 }
        public void ChangePassword(Earthwatcher ew)
        {
            client.Authenticator = new HttpBasicAuthenticator(Current.Instance.Username, Current.Instance.Password);

            var request = new RestRequest("password", Method.POST) { RequestFormat = DataFormat.Json };
            request.JsonSerializer = new JsonSerializer();
            request.AddBody(ew);

            client.ExecuteAsync<Earthwatcher>(request, response =>
               Deployment.Current.Dispatcher.BeginInvoke(() =>
                       PasswordChanged(
                           response.Data, null)
                    ));
        }
        public void GetLandByWkt(string wkt, int landId)
        {
            var request = new RestRequest("land/intersect", Method.POST) { RequestFormat = DataFormat.Json };
            request.JsonSerializer = new JsonSerializer();

            var earthwatcher = new Earthwatcher { Name = wkt, Id = landId };
            request.AddBody(earthwatcher);

            client.ExecuteAsync<List<Land>>(request, response =>
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                    LandInViewReceived(response.Data, null)
                    ));

        }
        public MainPage(Earthwatcher earthwatcher, string _geohexcode)
        {
            InitializeComponent();

            geohexcode = _geohexcode;

            //Logo
            this.logo.Source = ResourceHelper.GetBitmap(string.Format("/Resources/Images/{0}", Labels.LogoPath));

            Current.Instance.Earthwatcher = earthwatcher;
            Current.Instance.Username = earthwatcher.Name;
            Current.Instance.Password = earthwatcher.Password;
            Current.Instance.IsAuthenticated = true;
            Current.Instance.AddScore = new List<Score>();
            Current.Instance.MapControl = mapControl;
            this.DataContext = earthwatcher;

            if (earthwatcher.IsPowerUser)
            {
                this.badgeIcon.Source = Earthwatchers.UI.Resources.ResourceHelper.GetBitmap("/Resources/Images/badgej.png");
                ToolTipService.SetToolTip(this.badgeIcon, "Jaguar");
            }

            if (this.UserFullName.Text.Length > 14)
            {
                UserFullName.Text = Current.Instance.Earthwatcher.FullName.Substring(0, 13) + "...";
            }
            else
                UserFullName.Text = Current.Instance.Earthwatcher.FullName;

            scoreRequest.ScoresReceived += scoreRequest_ScoresReceived;
            scoreRequest.ScoreAdded += scoreRequest_ScoreAdded;
            scoreRequest.ScoreUpdated += scoreRequest_ScoreUpdated;
            scoreRequest.ServerDateTimeReceived += scoreRequest_ServerDateTimeReceived;
            Current.Instance.MapControl.zoomStarted += MapControl_zoomStarted;
            Current.Instance.MapControl.zoomFinished += MapControl_zoomFinished;

            Loaded += MainPageLoaded;
           
           


            //Current.Instance.Main = this; //TODO: remove after demo
        }
Exemple #18
0
        public static string GenerateCookie(Earthwatcher ew, bool keeplogued = true)
        {
            string compositeToken = Guid.NewGuid().ToString();
            string compositeEwName = ew.Name;
            string compositeEwRole = string.Join(",", ew.GetRoles());
            var expiresOn = keeplogued ? DateTime.UtcNow.AddDays(15) : DateTime.UtcNow.AddMinutes(30);
            var compositeExpiresOn = expiresOn.ToString(); 
            string composite = string.Format("{0}|{1}|{2}|{3}|{4}", compositeToken, compositeEwName, compositeEwRole, compositeExpiresOn, keeplogued);

            string strToken = TextEncrytion.EncryptString(composite, Session.secretKey);

            HttpCookie cookie = new HttpCookie(Session.TOKENKEY);
            cookie.Value = strToken;
            cookie.Expires = expiresOn;
            cookie.HttpOnly = false;
            System.Web.HttpContext.Current.Response.Cookies.Add(cookie);

            return strToken;
        }
        public MainPage(Earthwatcher earthwatcher)
        {
            InitializeComponent();

            Current.Instance.Earthwatcher = earthwatcher;
            Current.Instance.Username = earthwatcher.Name;
            Current.Instance.Password = earthwatcher.Password;
            Current.Instance.IsAuthenticated = true;
            Current.Instance.AddScore = new Dictionary<string, int>();
            this.DataContext = earthwatcher;

            scoreRequest.ScoresReceived += scoreRequest_ScoresReceived;
            scoreRequest.ScoreAdded += scoreRequest_ScoreAdded;
            scoreRequest.ScoreUpdated += scoreRequest_ScoreUpdated;

            Loaded += MainPageLoaded;

            Current.Instance.Main = this; //TODO: remove after demo
        }
        public MainPage(Earthwatcher earthwatcher, string _geohexcode)
        {
            InitializeComponent();

            HtmlPage.RegisterScriptableObject("JsFacebookCallback", this);

            geohexcode = _geohexcode;

            //Logo
            this.logo.Source = ResourceHelper.GetBitmap(string.Format("/Resources/Images/{0}", Labels.LogoPath));

            Current.Instance.Earthwatcher = earthwatcher;
            Current.Instance.PrecisionScore = 100;
            Current.Instance.Username = earthwatcher.Name;
            Current.Instance.Password = earthwatcher.Password;
            Current.Instance.IsAuthenticated = true;
            Current.Instance.AddScore = new List<Score>();
            Current.Instance.MapControl = mapControl;
            this.DataContext = earthwatcher;

            //Poner la bandera del pais en juego
            playingCountryFlag.Source = ResourceHelper.GetBitmap(string.Format("/Resources/Images/Flags/{0}-35.png", Current.Instance.Earthwatcher.PlayingRegion));

            if (this.UserFullName.Text.Length > 13)
            {
                UserFullName.Text = Current.Instance.Earthwatcher.FullName.Substring(0, 12) + "...";
            }
            else
                UserFullName.Text = Current.Instance.Earthwatcher.FullName;

            scoreRequest.ScoresReceived += scoreRequest_ScoresReceived;
            scoreRequest.ScoreAdded += scoreRequest_ScoreAdded;
            scoreRequest.ScoreUpdated += scoreRequest_ScoreUpdated;
            scoreRequest.ServerDateTimeReceived += scoreRequest_ServerDateTimeReceived;
            scoreRequest.PositionInRankingReceived += scoreRequest_PositionInRankingReceived;
            regionRequest.RegionReceived += regionRequest_RegionReceived;
            customShareTextRequest.TextsReceived += customShareTextRequest_TextsReceived;

            Current.Instance.MapControl.zoomStarted += MapControl_zoomStarted;
            Current.Instance.MapControl.zoomFinished += MapControl_zoomFinished;

            Loaded += MainPageLoaded;
        }
        public HttpResponseMessage ResetPassword(Earthwatcher earthwatcher, HttpRequestMessage<Earthwatcher> request)
        {
            if (earthwatcher != null)
            {
                try
                {
                    //Date
                    var encodedDateBytes = System.Convert.FromBase64String(earthwatcher.Region);
                    string encodedDate = System.Text.Encoding.UTF8.GetString(encodedDateBytes);
                    DateTime date = DateTime.MinValue;
                    DateTime.TryParse(encodedDate, out date);
                    if (date == DateTime.MinValue || date.AddDays(1) < DateTime.Now)
                    {
                        var response = new HttpResponseMessage(HttpStatusCode.BadRequest);
                        return response;
                    }

                    var earthwatcherDb = earthwatcherRepository.GetEarthwatcherByGuid(earthwatcher.Guid);
                    if (earthwatcherDb == null)
                    {
                        var response = new HttpResponseMessage(HttpStatusCode.NotFound);
                        return response;
                    }

                    PasswordResource pwd = new PasswordResource();
                    earthwatcherDb.Password = earthwatcher.Password;
                    pwd.GenerateAndUpdatePassword(earthwatcherDb);
                    return new HttpResponseMessage() { StatusCode = HttpStatusCode.OK };
                }
                catch (Exception ex)
                {
                    return new HttpResponseMessage() { StatusCode = HttpStatusCode.InternalServerError, ReasonPhrase = ex.Message };
                }
            }
            return new HttpResponseMessage() { StatusCode = HttpStatusCode.BadRequest };
        }
        public void GetPresicionDenouncePercentage(Earthwatcher e)
        {
            var request = new RestRequest("land/getPresicionDenouncePercentage", Method.POST) { RequestFormat = DataFormat.Json };
            request.JsonSerializer = new JsonSerializer();

            request.AddBody(e);
            client.ExecuteAsync<decimal>(request, response =>
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                    PresicionPercentageReceived(response.Content, null)
                    ));
        }
        public void GetVerifiedLandsGeoHexCodes(int earthwatcherId, bool isPoll)
        {
            client.Authenticator = new HttpBasicAuthenticator(Current.Instance.Username, Current.Instance.Password);

            var request = new RestRequest("land/verifiedlandscodes", Method.POST) { RequestFormat = DataFormat.Json };
            var earthwatcher = new Earthwatcher { Id = earthwatcherId, IsPowerUser = isPoll };
            request.AddBody(earthwatcher);

            client.ExecuteAsync<List<string>>(request, response =>
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                    VerifiedLandCodesReceived(response.Data, null)
                    ));
        }
        public HttpResponseMessage<Land> ReassignLand(Earthwatcher e, HttpRequestMessage<Earthwatcher> request)
        {
            if (e.Id!= 0)
            {
                try
                {
                    var newLand = landRepository.ReassignLand(e.Id);

                    if (newLand != null)
                    {
                        Land newLandObj = landRepository.GetLandByGeoHexKey(newLand.GeohexKey);
                        if (newLandObj != null)
                        {
                            newLandObj.EarthwatcherId = e.Id;
                            NotificateUsers(newLand, e.Id);
                            return new HttpResponseMessage<Land>(newLandObj) { StatusCode = HttpStatusCode.Created };
                        }
                    }
                    else
                    {
                        Land newLandObj = landRepository.GetTutorLand(e.PlayingRegion);
                        return new HttpResponseMessage<Land>(newLandObj) { StatusCode = HttpStatusCode.Created, ReasonPhrase = Labels.Labels.NoMoreLands };
                    }

                }
                catch (Exception ex)
                {
                    logger.Error("Ocurrio una excepcion en el ReasignLand. Message: {0},  StackTrace:{1}", ex.Message, ex.StackTrace);
                    return new HttpResponseMessage<Land>(null) { StatusCode = HttpStatusCode.Conflict, ReasonPhrase = ex.Message };
                }
            }

            return new HttpResponseMessage<Land>(null) { StatusCode = HttpStatusCode.BadRequest };
        }
        public void GetAll(int earthwatcherId, int playingRegion)
        {
            var request = new RestRequest("land/all", Method.POST) { RequestFormat = DataFormat.Json };
            //request.AddHeader("Accept-Encoding", "gzip, deflate");
            Earthwatcher e = new Earthwatcher();
            e.PlayingRegion = playingRegion;
            e.Id = earthwatcherId;
            request.JsonSerializer = new JsonSerializer();
            request.AddBody(e);

            client.ExecuteAsync<List<Land>>(request, response =>
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                    LandsReceived(response.Data, null)
                    ));
        }
        public ReportWindow(Land land, Earthwatcher earthwatcher)
        {
            InitializeComponent();

            selectedLand = land;

            string[] confirms = null;
            string[] deconfirms = null;

            if (!string.IsNullOrEmpty(selectedLand.DeforestationConfirmers))
            {
                confirms = selectedLand.DeforestationConfirmers.Split(',');
            }

            if (!string.IsNullOrEmpty(selectedLand.DeforestationDeconfirmers))
            {
                deconfirms = selectedLand.DeforestationDeconfirmers.Split(',');
            }

            if (Current.Instance.Earthwatcher.LandId.HasValue && Current.Instance.Earthwatcher.LandId == selectedLand.Id)
            {
                this.ReportGrid.Visibility = System.Windows.Visibility.Visible;
                this.ConfirmGrid.Visibility = System.Windows.Visibility.Collapsed;

                if (land.LandStatus == LandStatus.Alert)
                {
                    this.AlertButton.BorderThickness = new Thickness(4);
                    this.AlertButton.Background = new SolidColorBrush(Color.FromArgb(255, 241, 251, 187));
                }

                if (land.LandStatus == LandStatus.Ok)
                {
                    this.OkButton.BorderThickness = new Thickness(4);
                    this.OkButton.Background = new SolidColorBrush(Color.FromArgb(255, 241, 251, 187));
                }
            }
            else
            {
                this.Title.Text = "VALIDAR PARCELA EN ALERTA";
                this.ReportButton.Content = "VALIDAR";

                this.ReportGrid.Visibility = System.Windows.Visibility.Collapsed;
                this.ConfirmGrid.Visibility = System.Windows.Visibility.Visible;

                if (confirms != null && confirms.Any(x => x.Equals(Current.Instance.Earthwatcher.Id.ToString())))
                {
                    this.ConfirmButton.BorderThickness = new Thickness(4);
                    this.ConfirmButton.Background = new SolidColorBrush(Color.FromArgb(255, 241, 251, 187));

                    this.ConfirmButton.IsHitTestVisible = false;
                    this.ConfirmButton.Cursor = Cursors.Arrow;
                }

                if (deconfirms != null && deconfirms.Any(x => x.Equals(Current.Instance.Earthwatcher.Id.ToString())))
                {
                    this.DeconfirmButton.BorderThickness = new Thickness(4);
                    this.DeconfirmButton.Background = new SolidColorBrush(Color.FromArgb(255, 241, 251, 187));

                    this.DeconfirmButton.IsHitTestVisible = false;
                    this.DeconfirmButton.Cursor = Cursors.Arrow;
                }
            }

            //asocia esto a algún mensaje que muestre confirmación / deconfirmación
            if (land.LandStatus == LandStatus.Alert)
            {
                int countConfirm = 0;
                int countDeconfirm = 0;

                if (confirms != null)
                {
                    countConfirm = confirms.Length;
                }

                if (deconfirms != null)
                {
                    countDeconfirm = deconfirms.Length;
                }

                this.countConfirm1.Text = string.Format("{0} confirmaciones", countConfirm);
                this.countConfirm2.Text = string.Format("{0} confirmaciones", countConfirm);
                this.countDeConfirm1.Text = string.Format("{0} nada sospechoso", countDeconfirm);
                this.countDeConfirm2.Text = string.Format("{0} nada sospechoso", countDeconfirm);
            }
            else
            {
                this.countConfirm1.Visibility = System.Windows.Visibility.Collapsed;
                this.countConfirm2.Visibility = System.Windows.Visibility.Collapsed;
                this.countDeConfirm1.Visibility = System.Windows.Visibility.Collapsed;
                this.countDeConfirm2.Visibility = System.Windows.Visibility.Collapsed;
            }

            selectedEarthwatcher = earthwatcher;
            landRequests = new LandRequests(Constants.BaseApiUrl);
            hexagonLayer = (HexagonLayer)Current.Instance.LayerHelper.FindLayer(Constants.Hexagonlayername);

            this.Loaded += ReportWindow_Loaded;
        }
 public HttpResponseMessage SetEarthwatcherAsPowerUser(Earthwatcher earthwatcher, HttpRequestMessage<Earthwatcher> request)
 {
     var earthwatcherDb = earthwatcherRepository.GetEarthwatcher(earthwatcher.Name, false);
     if (earthwatcherDb != null)
     {
         earthwatcherRepository.SetEarthwatcherAsPowerUser(earthwatcherDb.Id, earthwatcherDb);
         return new HttpResponseMessage { StatusCode = HttpStatusCode.OK };
     }
     return new HttpResponseMessage { StatusCode = HttpStatusCode.NotFound };
 }
        public HttpResponseMessage UpdateEarthWatcher(Earthwatcher ew, HttpRequestMessage<Earthwatcher> request)
        {
            if (ew.MailChanged == true && ew.Name != null)
            {
                bool exists = earthwatcherRepository.EarthwatcherExists(ew.Name);
                if (exists == true)
                {
                    return new HttpResponseMessage { StatusCode = HttpStatusCode.MultipleChoices };
                }
            }

            if (ew != null)
            {
                earthwatcherRepository.UpdateEarthwatcher(ew.Id, ew);
                return new HttpResponseMessage { StatusCode = HttpStatusCode.OK };
            }
            return new HttpResponseMessage { StatusCode = HttpStatusCode.NotFound };
        }
 public HttpResponseMessage UpdateEarthWatcherRole(Earthwatcher ew, HttpRequestMessage<Earthwatcher> request)
 {
     var earthwatcherDb = earthwatcherRepository.GetEarthwatcher(ew.Name, false);
     if (earthwatcherDb != null)
     {
         earthwatcherDb.Role = ew.Role;
         earthwatcherRepository.UpdateEarthwatcher(earthwatcherDb.Id, earthwatcherDb);
         return new HttpResponseMessage { StatusCode = HttpStatusCode.OK };
     }
     return new HttpResponseMessage { StatusCode = HttpStatusCode.NotFound };
 }
 public HttpResponseMessage UpdateEarthwatcherAdmin(int id, Earthwatcher earthwatcher, HttpRequestMessage<Earthwatcher> request)
 {
     var earthwatcherDb = earthwatcherRepository.GetEarthwatcher(id);
     if (earthwatcherDb != null)
     {
         earthwatcherRepository.UpdateEarthwatcher(earthwatcher.Id, earthwatcher);
         return new HttpResponseMessage { StatusCode = HttpStatusCode.OK };
     }
     return new HttpResponseMessage { StatusCode = HttpStatusCode.NotFound };
 }