Esempio n. 1
0
        public bool Create(Application application, out int id)
        {
            id = -1;

            var checkApplication = _applicationRepository.Fetch(application.Name);

            if (checkApplication != null)
            {

                //if (checkApplication.Archived)
                 //{
                //     MessageBusService.AddIssue("");//ResourceManager.ApplicationManager_Create_ApplicationArchived()
                  //   return false;
                // }

                if (String.Equals(application.Name, checkApplication.Name, StringComparison.InvariantCultureIgnoreCase))
                {
                    MessageBusService.AddIssue(string.Format("An application with the name '{0}' already exists.", application.Name));//ResourceManager.CourseManager_Create_CourseNameExists()
                    return false;
                }

            }

            var uniqueRoleNames = !application.Roles.GroupBy(n => n.Name).Any(m => m.Count() > 1);

            if (!uniqueRoleNames)
            {
                MessageBusService.AddIssue("Role names should be unique!");
                return false;
            }

            var repApplication = Mapper.Map<Application, Rep.Application.Application>(application);
            if (_applicationRepository.Create(repApplication, out id))
            {
                var newApp = Fetch(id);
                AuditService.ObjectAuditLog(ActionType.Create, n => n.ID, newApp);

                EventManagerService.QueueEvent(new ApplicationCreatedEvent(newApp));

                return true;
            }

            //   MessageBusService.AddError(ResourceManager.CourseManager_Create_Error());
            return false;
        }
Esempio n. 2
0
        public bool Update(Application application)
        {
            var checkApplication = _applicationRepository.Fetch(application.Name);

            if (checkApplication != null)
            {
                if (String.Equals(application.Name, checkApplication.Name, StringComparison.InvariantCultureIgnoreCase) && application.ID != checkApplication.ID)
                {
                    MessageBusService.AddIssue(string.Format("An application with the name '{0}' already exists.", application.Name));
                    return false;
                }
            }

            var uniqueRoleNames = !application.Roles.GroupBy(n => n.Name).Any(m => m.Count() > 1);

            if (!uniqueRoleNames)
            {
                MessageBusService.AddIssue("Role names should be unique!");
                return false;
            }

            var repApp = Mapper.Map<Application, Rep.Application.Application>(application);
            if (_applicationRepository.Update(repApp))
            {
                var updated = Fetch(application.ID);
                AuditService.ObjectAuditLog(ActionType.Update, n => n.ID, updated);
                EventManagerService.QueueEvent(new ApplicationUpdatedEvent(updated));

                return true;
            }

            // MessageBusService.AddError(ResourceManager.CourseManager_Update_Error());
            return false;
        }
 public ApplicationDeletedEvent(Application application)
 {
     _application = application;
 }
 public ApplicationCreatedEvent(Application application)
 {
     _application = application;
 }
 public ApplicationUpdatedEvent(Application application)
 {
     _application = application;
 }
 public ApplicationRolledBackEvent(Application application)
 {
     _application = application;
 }