예제 #1
0
        public ActionConfirmation DeleteJefeArea(Guid id)
        {
            var item = _jefeAreaRepository.Get(id);

            if (item == null)
            {
                return(ActionConfirmation.CreateFailure("item no existe"));
            }

            try
            {
                if (item.Locales.Any())
                {
                    foreach (var local in item.Locales)
                    {
                        _localService.Delete(local.Id);
                    }
                }

                _jefeAreaRepository.Delete(item.Id);
                _jefeAreaRepository.DbContext.CommitChanges();

                return(ActionConfirmation.CreateSuccess("Delete OK (" + item.Nombre + ")"));
            }
            catch (Exception exception)
            {
                _eventLogService.AddException(exception.Message,
                                              exception.StackTrace, EventCategory.EliminarObjeto.ToString(), exception, item.ActualizadoPor, EventSource.Sistema);

                return(ActionConfirmation.CreateFailure(exception.ToString()));
            }
        }
예제 #2
0
        public ActionConfirmation QueueSendingFailure(int itemId, int failureInterval, int maxNumberOfTries)
        {
            var emailToQueue = _queueRepository.Get(itemId);

            if (emailToQueue != null)
            {
                try
                {
                    _queueRepository.QueueSendingFailure(emailToQueue, failureInterval, maxNumberOfTries);

                    var confirmation =
                        ActionConfirmation.CreateSuccess(
                            "The email was successfully queued for sending failure");
                    confirmation.Value = emailToQueue;

                    return(confirmation);
                }
                catch (Exception)
                {
                    return
                        (ActionConfirmation.CreateFailure(
                             "A problem was encountered preventing the email queue sending failure"));
                }
            }

            return
                (ActionConfirmation.CreateFailure(
                     "The email could not be found to queue failure. It may already have been deleted"));
        }
예제 #3
0
        /// <summary>
        /// Saves the or update.
        /// </summary>
        /// <param name="logItem">The log item.</param>
        /// <returns></returns>
        public ActionConfirmation SaveOrUpdate(LogItem logItem)
        {
            try
            {
                if (logItem.IsValid())
                {
                    this._logItemRepository.SaveOrUpdate(logItem);
                    _logItemRepository.DbContext.CommitChanges();


                    ActionConfirmation confirmation = ActionConfirmation.CreateSuccess("Log Added!");
                    confirmation.Value = logItem;

                    return(confirmation);
                }
                else
                {
                    this._logItemRepository.DbContext.RollbackTransaction();

                    return
                        (ActionConfirmation.CreateFailure(
                             "The log item could not be saved due to missing or invalid information"));
                }
            }
            catch (Exception exception)
            {
                return(ActionConfirmation.CreateFailure("Cannot insert into the log > " + exception.Message));
            }
        }
예제 #4
0
        public ActionConfirmation Delete(int itemId)
        {
            var emailToDelete = _queueRepository.Get(itemId);

            if (emailToDelete != null)
            {
                try
                {
                    _queueRepository.Delete(emailToDelete);
                    _queueRepository.DbContext.CommitChanges();

                    return(ActionConfirmation.CreateSuccess("The email was successfully deleted."));
                }
                catch
                {
                    return
                        (ActionConfirmation.CreateFailure(
                             "A problem was encountered preventing the email from being deleted. " +
                             "Another item likely depends on this email"));
                }
            }

            return
                (ActionConfirmation.CreateFailure(
                     "The email could not be found to deletion. It may already have been deleted"));
        }
예제 #5
0
        public ActionConfirmation Queue(EmailQueueItem item)
        {
            try
            {
                if (item.IsValid())
                {
                    _queueRepository.SaveOrUpdate(item);
                    _queueRepository.DbContext.CommitChanges();

                    var saveOrUpdateConfirmation = ActionConfirmation.CreateSuccess("The emails were successfully queued.");
                    saveOrUpdateConfirmation.Value = item;

                    return(saveOrUpdateConfirmation);
                }
                else
                {
                    _queueRepository.DbContext.RollbackTransaction();

                    return
                        (ActionConfirmation.CreateFailure(
                             "The item could not be queued due to missing or invalid information"));
                }
            }
            catch (Exception exception)
            {
                return
                    (ActionConfirmation.CreateFailure(
                         "The email could not be saved due to missing or invalid information > " + exception.Message));
            }
        }
예제 #6
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!"));
            }
        }
예제 #7
0
        public ActionConfirmation SaveOrUpdateComentario(RespuestaComentario respuestaComentario)
        {
            if (!respuestaComentario.IsValid())
            {
                return(ActionConfirmation.CreateFailure("respuesta no es válida"));
            }

            try
            {
                _comentarioRepository.SaveOrUpdate(respuestaComentario);
                _comentarioRepository.DbContext.CommitChanges();

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

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

                return(ActionConfirmation.CreateFailure(exception.ToString()));
            }
        }
예제 #8
0
        public ActionConfirmation SaveOrUpdateImagen(ImagenLocal imagenLocal)
        {
            if (!imagenLocal.IsValid())
            {
                return(ActionConfirmation.CreateFailure("imagenLocal no es válida"));
            }

            try
            {
                _imagenRepository.SaveOrUpdate(imagenLocal);
                _imagenRepository.DbContext.CommitChanges();

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

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

                return(ActionConfirmation.CreateFailure(exception.ToString()));
            }
        }
예제 #9
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()));
            }
        }
예제 #10
0
        public ActionConfirmation Delete(IdentityRole role)
        {
            try
            {
                _roleRepository.Delete(role);
                _roleRepository.DbContext.CommitChanges();

                return(ActionConfirmation.CreateSuccess("role deleted"));
            }
            catch (Exception exception)
            {
                return(ActionConfirmation.CreateFailure("error > " + exception.Message));
            }
        }
예제 #11
0
        public ActionConfirmation Delete(IdentityUser user)
        {
            try
            {
                _userRepository.Delete(user);
                _userRepository.DbContext.CommitChanges();

                return(ActionConfirmation.CreateSuccess("user deleted"));
            }
            catch (Exception exception)
            {
                return(ActionConfirmation.CreateFailure("error > " + exception.Message));
            }
        }
예제 #12
0
        public ActionConfirmation SaveOrUpdateUserProfile(PerfilUsuario perfilUsuario)
        {
            try
            {
                _userProfileRepository.SaveOrUpdate(perfilUsuario);
                _userProfileRepository.DbContext.CommitChanges();

                return(ActionConfirmation.CreateSuccess("saved ok"));
            }
            catch (System.Exception exception)
            {
                return(ActionConfirmation.CreateFailure(exception.ToString()));
            }
        }
예제 #13
0
        public ActionConfirmation SaveOrUpdateRegion(Region region)
        {
            if (!region.IsValid())
            {
                return(ActionConfirmation.CreateFailure("not valid"));
            }

            try
            {
                _regionRepository.SaveOrUpdate(region);
                _regionRepository.DbContext.CommitChanges();

                return(ActionConfirmation.CreateSuccess("saved ok"));
            }
            catch (Exception exception)
            {
                return(ActionConfirmation.CreateFailure(exception.ToString()));
            }
        }
예제 #14
0
        public ActionConfirmation SaveOrUpdateGroup(Grupo grupo)
        {
            if (!grupo.IsValid())
            {
                return(ActionConfirmation.CreateFailure("not valid"));
            }

            try
            {
                _groupRepository.SaveOrUpdate(grupo);
                _groupRepository.DbContext.CommitChanges();

                return(ActionConfirmation.CreateSuccess("saved ok"));
            }
            catch (System.Exception exception)
            {
                return(ActionConfirmation.CreateFailure(exception.ToString()));
            }
        }
예제 #15
0
        public ActionConfirmation SaveOrUpdateUser(Usuario usuario)
        {
            if (!usuario.IsValid())
            {
                return(ActionConfirmation.CreateFailure("invalid object"));
            }

            try
            {
                _userRepository.SaveOrUpdate(usuario);
                _userRepository.DbContext.CommitChanges();

                return(ActionConfirmation.CreateSuccess("ok"));
            }
            catch (System.Exception exception)
            {
                return(ActionConfirmation.CreateFailure(exception.ToString()));
            }
        }
예제 #16
0
        public ActionConfirmation SaveOrUpdate(Project project)
        {
            if (!project.IsValid())
            {
                return(ActionConfirmation.CreateFailure("proyecto no valido"));
            }

            try
            {
                _projectRepository.SaveOrUpdate(project);
                _projectRepository.DbContext.CommitChanges();

                return(ActionConfirmation.CreateSuccess("saved ok"));
            }
            catch (System.Exception exception)
            {
                return(ActionConfirmation.CreateFailure(exception.ToString()));
            }
        }
예제 #17
0
        public ActionConfirmation SaveOrUpdateMember(ProjectMember member)
        {
            if (!member.IsValid())
            {
                return(ActionConfirmation.CreateFailure("miembro no válido"));
            }

            try
            {
                _memberRepository.SaveOrUpdate(member);
                _memberRepository.DbContext.CommitChanges();

                return(ActionConfirmation.CreateSuccess("member created"));
            }
            catch (System.Exception exception)
            {
                return(ActionConfirmation.CreateFailure(exception.ToString()));
            }
        }
예제 #18
0
        public ActionConfirmation SaveOrUpdate(IdentityRole role)
        {
            if (role.IsValid())
            {
                try
                {
                    _roleRepository.SaveOrUpdate(role);
                    _roleRepository.DbContext.CommitChanges();

                    return(ActionConfirmation.CreateSuccess("role saved"));
                }
                catch (Exception exception)
                {
                    return(ActionConfirmation.CreateFailure("error > " + exception.Message));
                }
            }
            else
            {
                return(ActionConfirmation.CreateFailure("role is not valid"));
            }
        }
예제 #19
0
        public ActionConfirmation SaveOrUpdate(IdentityUser user)
        {
            if (user.IsValid())
            {
                try
                {
                    _userRepository.SaveOrUpdate(user);
                    _userRepository.DbContext.CommitChanges();

                    return(ActionConfirmation.CreateSuccess("user saved"));
                }
                catch (Exception exception)
                {
                    return(ActionConfirmation.CreateFailure("error > " + exception.Message));
                }
            }
            else
            {
                return(ActionConfirmation.CreateFailure("user is not valid"));
            }
        }
예제 #20
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()));
            }
        }
예제 #21
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);
        }
예제 #22
0
        public ActionConfirmation Delete(int id)
        {
            var setting = Get(id);

            if (setting == null)
            {
                return(ActionConfirmation.CreateFailure("Setting does not exist"));
            }

            try
            {
                _settingRepository.Delete(setting.Id);
                return(ActionConfirmation.CreateSuccess("setting deleted!"));
            }
            catch (System.Exception exception)
            {
                _eventLogService.AddException(exception.Message, exception.StackTrace, EventCategory.EliminarObjeto.ToString(), exception, "", EventSource.Sistema);

                var confirmation = ActionConfirmation.CreateFailure("setting not deleted | " + exception);
                return(confirmation);
            }
        }
예제 #23
0
        public ActionConfirmation Delete(Guid id)
        {
            var status = Get(id);

            if (status == null)
            {
                return(ActionConfirmation.CreateFailure("Status no existe"));
            }

            try
            {
                _statusRepository.Delete(status);
                return(ActionConfirmation.CreateSuccess("status borrado!"));
            }
            catch (System.Exception exception)
            {
                _eventLogService.AddException(exception.Message, exception.StackTrace, EventCategory.EliminarObjeto.ToString(), exception, "", EventSource.Sistema);

                var confirmation = ActionConfirmation.CreateFailure("status no eliminado | " + exception);
                return(confirmation);
            }
        }
예제 #24
0
        public ActionConfirmation SaveOrUpdateGeneral(GerenteGeneral gerenteGeneral)
        {
            if (!gerenteGeneral.IsValid())
            {
                return(ActionConfirmation.CreateFailure("item no es válido"));
            }

            try
            {
                _generalRepository.SaveOrUpdate(gerenteGeneral);
                _generalRepository.DbContext.CommitChanges();

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

                return(ActionConfirmation.CreateFailure(exception.ToString()));
            }
        }
예제 #25
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()));
            }
        }
예제 #26
0
        public ActionConfirmation SaveOrUpdateSistema(Sistema item)
        {
            if (!item.IsValid())
            {
                return(ActionConfirmation.CreateFailure("objeto no es válida"));
            }

            try
            {
                _sistemaRepository.SaveOrUpdate(item);
                _sistemaRepository.DbContext.CommitChanges();

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

                return(ActionConfirmation.CreateFailure(exception.ToString()));
            }
        }
예제 #27
0
        public ActionConfirmation Delete(string userId)
        {
            var user = _userRepository.GetById(userId);

            if (user != null)
            {
                try
                {
                    _userRepository.Delete(user);
                    _userRepository.DbContext.CommitChanges();

                    return(ActionConfirmation.CreateSuccess("user deleted"));
                }
                catch (Exception exception)
                {
                    return(ActionConfirmation.CreateFailure("error > " + exception.Message));
                }
            }
            else
            {
                return(ActionConfirmation.CreateFailure("user does not exist"));
            }
        }
예제 #28
0
        public ActionConfirmation QueueGenericEmail(string to, string @from, string subject, string body)
        {
            var formatList = new FormatList();

            formatList.Add("Body", body);
            formatList.Add("useremail", from);
            formatList.Add("Subject", subject);


            var email = GenericEmail("GenericEmail", null, null, true);

            if (email == null)
            {
                return(ActionConfirmation.CreateFailure("Email template not found!"));
            }

            email.To      = to;
            email.From    = from;
            email.Body    = formatList.Format(email.Body);
            email.Subject = formatList.Format(email.Subject);

            return(_queueService.Queue(email));
        }
예제 #29
0
        public ActionConfirmation DeleteOpcion(Guid id)
        {
            var item = _opcionRepository.Get(id);

            if (item == null)
            {
                return(ActionConfirmation.CreateFailure("objeto no existe"));
            }

            try
            {
                _opcionRepository.Delete(item.Id);
                _opcionRepository.DbContext.CommitChanges();

                return(ActionConfirmation.CreateSuccess("Delete OK (" + item.Nombre + ")"));
            }
            catch (Exception exception)
            {
                _eventLogService.AddException(exception.Message,
                                              exception.StackTrace, EventCategory.EliminarObjeto.ToString(), exception, item.ActualizadoPor, EventSource.Sistema);

                return(ActionConfirmation.CreateFailure(exception.ToString()));
            }
        }
예제 #30
0
        public ActionConfirmation CreateRespuestasByEvaluacion(Guid evaluacionId)
        {
            var evaluacion = Get(evaluacionId);

            if (evaluacion == null)
            {
                return(ActionConfirmation.CreateFailure("item no existe"));
            }

            try
            {
                var responsesToCreate = new List <Estandar>();

                var groups = _estandarService.GetGruposList();
                foreach (var grupoEstandar in groups)
                {
                    var headers = _estandarService.GetByGrupo(grupoEstandar.Id);
                    foreach (var header in headers)
                    {
                        var estandares = _estandarService.GetByParent(header.Id);
                        foreach (var estandar in estandares)
                        {
                            responsesToCreate.Add(estandar);

                            var picklist = _estandarService.GetPicklist(estandar.Id);
                            responsesToCreate.AddRange(picklist);

                            var subEstandares = _estandarService.GetByParent(estandar.Id);
                            foreach (var subEstandar in subEstandares)
                            {
                                responsesToCreate.Add(subEstandar);

                                var subpicklist = _estandarService.GetPicklist(subEstandar.Id);
                                responsesToCreate.AddRange(subpicklist);

                                var childEstandares = _estandarService.GetByParent(subEstandar.Id);
                                foreach (var childEstandar in childEstandares)
                                {
                                    responsesToCreate.Add(childEstandar);

                                    var childpicklist = _estandarService.GetPicklist(childEstandar.Id);
                                    responsesToCreate.AddRange(childpicklist);

                                    var subchildEstandares = _estandarService.GetByParent(childEstandar.Id);
                                    foreach (var subchildEstandar in subchildEstandares)
                                    {
                                        responsesToCreate.Add(subchildEstandar);

                                        var subchildpicklist = _estandarService.GetPicklist(subchildEstandar.Id);
                                        responsesToCreate.AddRange(subchildpicklist);
                                    }
                                }
                            }
                        }
                    }
                }

                // Create Responses
                var respCreated = new List <Respuesta>();
                if (responsesToCreate.Any())
                {
                    foreach (var estandar in responsesToCreate)
                    {
                        var respuesta = new Respuesta
                        {
                            Detalle        = "",
                            FechaRespuesta = DateTime.Now,
                            CreadoPor      = evaluacion.CreadoPor,
                            CreadoEn       = DateTime.Now,
                            ActualizadoPor = evaluacion.ActualizadoPor,
                            ActualizadoEn  = DateTime.Now,
                            Estandar       = estandar,
                            Evaluacion     = evaluacion,
                            Valor          = (short)ValorRespuesta.Nulo
                        };


                        var respConfirmation = _respuestaService.SaveOrUpdate(respuesta);
                        if (respConfirmation.WasSuccessful)
                        {
                            if (estandar.TipoEstandar == (short)TipoEstandar.Estandar)
                            {
                                var dbResponse = _respuestaService.Get(respuesta.Id);
                                var comment    = new RespuestaComentario
                                {
                                    Detalle        = "",
                                    Valor          = "",
                                    CreadoPor      = evaluacion.CreadoPor,
                                    CreadoEn       = DateTime.Now,
                                    ActualizadoPor = evaluacion.ActualizadoPor,
                                    ActualizadoEn  = DateTime.Now,
                                    Respuesta      = dbResponse
                                };

                                var commentConfirm = _respuestaService.SaveOrUpdateComentario(comment);
                            }

                            respCreated.Add(respuesta);
                        }
                    }
                }

                return(ActionConfirmation.CreateSuccess($"respuestas creadas ({respCreated.Count})"));
            }
            catch (Exception exception)
            {
                _eventLogService.AddException(exception.Message,
                                              exception.StackTrace, EventCategory.GuardarObjeto.ToString(), exception, evaluacion.ActualizadoPor, EventSource.Sistema);

                return(ActionConfirmation.CreateFailure(exception.ToString()));
            }
        }