Example #1
0
        public bool SaveActions(EntityServiceCollection records)
        {
            if (records == null)
            {
                throw new ArgumentNullException("records");
            }

            bool result = true;

            Guid[]            typeIds     = records.Select(re => re.Item2).ToArray();
            var               groupId     = StrixPlatform.User.GroupId;
            List <EntityType> entityTypes = this._dataSource.Query <EntityType>().Include(t => t.EntityTypeServiceActions).Where(e => typeIds.Contains(e.Id)).ToList();

            foreach (var entityType in entityTypes)
            {
                var actions = entityType.EntityTypeServiceActions.Where(s => s.GroupId == groupId).ToList();
                this._dataSource.Delete(actions);

                foreach (var action in actions)
                {
                    entityType.EntityTypeServiceActions.Remove(action);
                }
            }

            foreach (var group in records)
            {
                SaveRecord(group, entityTypes, groupId);
            }

            return(result);
        }
Example #2
0
        public EntityServiceCollection GetManagerActionRecords()
        {
            var result = new EntityServiceCollection();

            foreach (var type in EntityHelper.EntityTypes.OrderBy(t => t.Name))
            {
                var records = new List <ServiceActionRecord>();

                foreach (var service in StrixCms.Services)
                {
                    foreach (var action in service.Value)
                    {
                        var existingRecord = type.EntityTypeServiceActions != null?
                                             type.EntityTypeServiceActions.FirstOrDefault(r => r.Action == action) :
                                                 null;

                        records.Add(new ServiceActionRecord
                        {
                            Id           = existingRecord != null ? existingRecord.Id : 0,
                            EntityTypeId = type.Id,
                            Action       = action,
                            Service      = service.Key,
                            Selected     = existingRecord != null
                        });
                    }
                }

                result.Add(new Tuple <string, Guid, IList <ServiceActionRecord> >(type.Name.Split('.').Last().Replace("Entity", string.Empty), type.Id, records));
            }

            return(result);
        }
Example #3
0
        public JsonResult SaveData(EntityServiceCollection records)
        {
            JsonStatusResult status = new JsonStatusResult();

            if (records.IsEmpty())
            {
                status.Message = StrixIT.Platform.Modules.Cms.Resources.Interface.NoRecordsToSave;
                return(this.Json(status));
            }

            status.Success = this._service.SaveActionRecords(records);

            if (!status.Success)
            {
                status.Message = StrixIT.Platform.Modules.Cms.Resources.Interface.ErrorSavingServiceAction;
            }

            return(status);
        }