Exemple #1
0
        public ActionConfirmation SaveOrUpdate(Setting dbSetting)
        {
            if (dbSetting.IsValid())
            {
                try
                {
                    _settingRepository.SaveOrUpdate(dbSetting);
                    _settingRepository.DbContext.CommitChanges();

                    return(ActionConfirmation.CreateSuccess("setting saved ok!"));
                }
                catch (System.Exception exception)
                {
                    _eventLogService.AddException(exception.Message,
                                                  exception.StackTrace, EventCategory.GuardarObjeto.ToString(), exception, dbSetting.UpdatedBy, EventSource.Sistema);

                    var confirmation = ActionConfirmation.CreateFailure("setting not saved | " + exception.ToString());
                    return(confirmation);
                }
            }
            else
            {
                return(ActionConfirmation.CreateFailure("setting is not valid!"));
            }
        }
Exemple #2
0
        public ActionConfirmation SaveOrUpdate(Respuesta respuesta)
        {
            if (!respuesta.IsValid())
            {
                return(ActionConfirmation.CreateFailure("respuesta no es válida"));
            }

            try
            {
                _respuestaRepository.SaveOrUpdate(respuesta);
                _respuestaRepository.DbContext.CommitChanges();

                var confirmation = ActionConfirmation.CreateSuccess("Respuesta " + respuesta.Id + " guardada!");
                confirmation.Value = respuesta;

                return(confirmation);
            }
            catch (Exception exception)
            {
                _eventLogService.AddException(exception.Message,
                                              exception.StackTrace, EventCategory.GuardarObjeto.ToString(), exception, respuesta.ActualizadoPor, EventSource.Sistema);

                return(ActionConfirmation.CreateFailure(exception.ToString()));
            }
        }
Exemple #3
0
        public ActionConfirmation SaveOrUpdate(Estado estado)
        {
            if (!estado.IsValid())
            {
                return(ActionConfirmation.CreateFailure("not valid!"));
            }

            try
            {
                _statusRepository.SaveOrUpdate(estado);
                _statusRepository.DbContext.CommitChanges();

                return(ActionConfirmation.CreateSuccess("saved ok"));
            }
            catch (Exception exception)
            {
                _eventLogService.AddException(exception.Message,
                                              exception.StackTrace, EventCategory.GuardarObjeto.ToString(), exception, estado.ActualizadoPor, EventSource.Sistema);
                return(ActionConfirmation.CreateFailure(exception.ToString()));
            }
        }
Exemple #4
0
        public ActionConfirmation SaveOrUpdate(Evaluacion evaluacion)
        {
            if (!evaluacion.IsValid())
            {
                return(ActionConfirmation.CreateFailure("evaluación no es válida"));
            }

            try
            {
                _evaluacionRepository.SaveOrUpdate(evaluacion);
                _evaluacionRepository.DbContext.CommitChanges();

                var confirmation = ActionConfirmation.CreateSuccess("Evaluacion " + evaluacion.Id + " guardada!");
                confirmation.Value = evaluacion;

                return(confirmation);
            }
            catch (Exception exception)
            {
                _eventLogService.AddException(exception.Message,
                                              exception.StackTrace, EventCategory.GuardarObjeto.ToString(), exception, evaluacion.ActualizadoPor, EventSource.Sistema);

                return(ActionConfirmation.CreateFailure(exception.ToString()));
            }
        }
Exemple #5
0
        public ActionConfirmation SaveOrUpdateProvincia(Provincia provincia)
        {
            if (!provincia.IsValid())
            {
                ActionConfirmation.CreateFailure("provincia no válida");
            }

            try
            {
                _provinciaRepository.SaveOrUpdate(provincia);
                _provinciaRepository.DbContext.CommitChanges();

                return(ActionConfirmation.CreateSuccess("saved ok"));
            }
            catch (Exception exception)
            {
                _eventLogService.AddException(exception.Message,
                                              exception.StackTrace, EventCategory.GuardarObjeto.ToString(), exception, provincia.ActualizadoPor, EventSource.Sistema);

                return(ActionConfirmation.CreateFailure(exception.ToString()));
            }
        }
Exemple #6
0
        public ActionConfirmation SaveOrUpdate(Local local)
        {
            if (!local.IsValid())
            {
                return(ActionConfirmation.CreateFailure("cadena no es válida"));
            }

            try
            {
                _localRepository.SaveOrUpdate(local);
                _localRepository.DbContext.CommitChanges();

                return(ActionConfirmation.CreateSuccess("saved ok"));
            }
            catch (Exception exception)
            {
                _eventLogService.AddException(exception.Message,
                                              exception.StackTrace, EventCategory.GuardarObjeto.ToString(), exception, local.ActualizadoPor, EventSource.Sistema);

                return(ActionConfirmation.CreateFailure(exception.ToString()));
            }
        }
Exemple #7
0
        public string UploadImage(HttpPostedFileBase image, string blobContainer)
        {
            string imageFullPath = null;

            if (image == null || image.ContentLength == 0)
            {
                return(null);
            }

            try
            {
                var cloudStorageAccount = GetConnectionString();
                var cloudBlobClient     = cloudStorageAccount.CreateCloudBlobClient();
                var cloudBlobContainer  = cloudBlobClient.GetContainerReference(blobContainer);

                if (cloudBlobContainer.CreateIfNotExists())
                {
                    cloudBlobContainer.SetPermissions(new BlobContainerPermissions
                    {
                        PublicAccess = BlobContainerPublicAccessType.Blob
                    });
                }

                var imageName = Guid.NewGuid() + "-" + Path.GetExtension(image.FileName);

                var cloudBlockBlob = cloudBlobContainer.GetBlockBlobReference(imageName);
                cloudBlockBlob.Properties.ContentType = image.ContentType;
                cloudBlockBlob.UploadFromStream(image.InputStream);

                imageFullPath = cloudBlockBlob.Uri.ToString();
            }
            catch (Exception exception)
            {
                _eventLogService.AddException(exception.Message, exception.Message, "images", exception);
                throw exception;
            }

            return(imageFullPath);
        }
Exemple #8
0
        /// <summary>
        ///   Adds the specified activity type.
        /// </summary>
        /// <param name = "activityType">Type of the activity.</param>
        /// <param name = "eventType">Type of the event.</param>
        /// <param name = "message">The message.</param>
        /// <param name = "objectId">The object id.</param>
        /// <param name = "objectType">Type of the object.</param>
        /// <param name = "username">The username.</param>
        /// <returns></returns>
        public ActionConfirmation Add(
            string activityType,
            EventType eventType,
            string message,
            string objectId,
            string objectType,
            string username)
        {
            var logItem = new LogItem
            {
                Category           = EventCategory.Actividad.ToString(),
                EventDate          = DateTime.Now,
                IsVisible          = true,
                Message            = activityType,
                MessageDescription = message,
                Username           = username,
                ObjectId           = objectId,
                ObjectType         = objectType,
                EventType          = (short)eventType,
                Source             = EventSource.Sistema.ToString()
            };

            ActionConfirmation confirmation;

            try
            {
                _eventLogService.Write(logItem);
                confirmation = ActionConfirmation.CreateSuccess("Activity Added");
            }
            catch (Exception exception)
            {
                _eventLogService.AddException(
                    exception.Message, exception.ToString(), EventCategory.NoDefinida.ToString(), exception);

                confirmation =
                    ActionConfirmation.CreateFailure("Activity cannot be added > " + exception.Message);
            }

            return(confirmation);
        }