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; }
public bool SaveActionRecords(EntityServiceCollection records) { var result = this._manager.SaveActions(records); this._dataSource.SaveChanges(); return(result); }
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; }
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; }
public bool SaveActionRecords(EntityServiceCollection records) { var result = this._manager.SaveActions(records); this._dataSource.SaveChanges(); return result; }