//public async Task<string> Validate(NotificationEventInput input) {
        //    string errors = string.Empty;
        //    if (!string.IsNullOrWhiteSpace(input.Id)) {  //PUT
        //        var existsId = await existElement.ExistsById<NotificationEvent>(input.Id, false);
        //        if (!existsId)
        //            errors += $"No existe notificación con id {input.Id}.";
        //    }
        //    var existsBarrack = await existElement.ExistsById<Barrack>(input.IdBarrack, false);
        //    if (!existsBarrack)
        //        errors += $"No existe cuartel con id {input.IdBarrack}.";
        //    if (input.NotificationType == NotificationType.Phenological) {
        //        var existsPhenologicalEvent = await existElement.ExistsById<PhenologicalEvent>(input.IdPhenologicalEvent, false);
        //        if (!existsPhenologicalEvent)
        //            errors += $"No existe evento fenológico con id {input.IdPhenologicalEvent}.";
        //    }
        //    return errors.Replace(".",".\r\n");
        //}

        public async Task <ExtPostContainer <string> > Save(NotificationEvent notificationEvent)
        {
            //TODO: Revisar
            var picturePath = await uploadImage.UploadImageBase64(notificationEvent.PicturePath);

            notificationEvent.PicturePath = picturePath;
            await repo.CreateUpdate(notificationEvent);

            search.AddDocument(notificationEvent);

            //TODO: Definir el origen de la lista de idsRoles
            var usersEmails = await commonQueries.GetUsersMailsFromRoles(new List <string> {
                "24beac75d4bb4f8d8fae8373426af780"
            });

            email.SendEmail(usersEmails, "Notificacion",
                            $@"<html>
                    <body>
                        <p> Estimado(a), </p>
                        <p> Llego una notificacion </p>
                        <img src='{picturePath}' style='width:50%;height:auto;'>
                        <p> Atentamente,<br> -Aresa </br></p>
                    </body>
                </html>");
            return(new ExtPostContainer <string> {
                IdRelated = notificationEvent.Id,
                MessageResult = ExtMessageResult.Ok
            });
        }
        public override async Task <ExtPostContainer <string> > SaveInput(NotificationEventInput input)
        {
            await Validate(input);

            var id          = !string.IsNullOrWhiteSpace(input.Id) ? input.Id : Guid.NewGuid().ToString("N");
            var picturePath = await uploadImage.UploadImageBase64(input.Base64);


            NotificationEvent notification = new NotificationEvent {
                Id                  = id,
                Created             = DateTime.Now,
                IdBarrack           = input.IdBarrack,
                IdPhenologicalEvent = input.IdPhenologicalEvent,
                NotificationType    = input.NotificationType,
                PicturePath         = picturePath,
                Description         = input.Description,
            };

            //TODO: Cambiar tipo de dato a GeoSpacial
            #if !CONNECT
            if (input.Location != null)
            {
                notification.Location = new Point(input.Location.Lng, input.Location.Lat);
                notification.Weather  = await weather.GetWeather((float)input.Location.Lat, (float)input.Location.Lng);
            }
            #endif

            await SaveDb(notification);

            var usersEmails = await commonQueries.GetUsersMailsFromRoles(new List <string> {
                "24beac75d4bb4f8d8fae8373426af780"
            });

            email.SendEmail(usersEmails, "Notificacion",
                            $@"<html>
                    <body>
                        <p> Estimado(a), </p>
                        <p> Llego una notificacion </p>
                        <img src='{picturePath}' style='width:50%;height:auto;'>
                        <p> Atentamente,<br> -Aresa </br></p>
                    </body>
                </html>");

            return(await SaveSearch(notification));
        }