Exemple #1
0
        // GET: Manager/Collections/Edit/5
        public ActionResult Edit(int?id, int?entityTypeId)
        {
            CFCollection model;

            if (id.HasValue && id.Value > 0)
            {
                model = CollectionService.GetCollection(id.Value);
                if (model == null)
                {
                    return(HttpNotFound("Collection was not found"));
                }
            }
            else
            {
                if (entityTypeId.HasValue)
                {
                    model = CollectionService.CreateCollection(entityTypeId.Value);
                }
                else
                {
                    List <CFEntityType> entityTypes = EntityTypeService.GetEntityTypes(CFEntityType.eTarget.Collections).ToList();
                    ViewBag.SelectEntityViewModel = new SelectEntityTypeViewModel()
                    {
                        EntityTypes = entityTypes
                    };

                    model = new CFCollection();
                }
            }

            return(View(model));
        }
        // GET: Manager/Items
        public ActionResult Index(int offset = 0, int limit = int.MaxValue, int?typeId = null)
        {
            SecurityService.CreateAccessContext();
            if (limit == int.MaxValue)
            {
                limit = ConfigHelper.PageSize;
            }

            var itemQuery = ItemService.GetItems();

            if (typeId != null)
            {
                itemQuery = itemQuery.Where(i => i.EntityTypeId == typeId.Value);
            }

            var entities = itemQuery.OrderBy(e => e.Id).Skip(offset).Take(limit).Include(e => (e as CFEntity).EntityType).Select(e => e as CFEntity);
            var total    = itemQuery.Count();

            ViewBag.TotalItems   = total;
            ViewBag.Limit        = limit;
            ViewBag.Offset       = offset;
            ViewBag.SelectedType = typeId;

            var _eTypes = new SelectList(EntityTypeService.GetEntityTypes(CFEntityType.eTarget.Items).OrderBy(e => e.Name), "Id", "Name");

            ViewBag.EntityTypes = JsonConvert.SerializeObject(_eTypes.ToList());
            // ViewBag.EntityTypes = new SelectList(EntityTypeService.GetEntityTypes(CFEntityType.eTarget.Items), "Id", "Name", typeId);

            if (entities != null)
            {
                return(View(entities));
            }

            return(View());
        }
        // GET: Manager/Items/Edit/5
        public ActionResult Edit(int?id, int?entityTypeId)
        {
            SecurityService.CreateAccessContext();
            CFItem model;

            if (id.HasValue && id.Value > 0)
            {
                model = ItemService.GetItem(id.Value);
                if (model == null)
                {
                    return(HttpNotFound("Item was not found"));
                }
                //Sept 27 2019 -- set the READ ONLY
                if (!Catfish.Core.Contexts.AccessContext.current.IsAdmin)//not admin
                {
                    string accessMode = "";
                    foreach (CFAccessGroup ag in model.AccessGroups)
                    {
                        accessMode = ag.AccessDefinition.AccessModes.ToString();
                        if (accessMode == "Read")
                        {
                            ViewBag.ReadOnly = true;
                        }
                        else if (accessMode == "Write")
                        {
                            ViewBag.ReadOnly = false;
                            break;
                        }
                    }
                }
            }
            else
            {
                if (entityTypeId.HasValue)
                {
                    model = ItemService.CreateItem(entityTypeId.Value);
                }
                else
                {
                    List <CFEntityType> entityTypes = EntityTypeService.GetEntityTypes(CFEntityType.eTarget.Items).ToList(); //srv.GetEntityTypes(EntityType.eTarget.Items).ToList();
                    ViewBag.SelectEntityViewModel = new SelectEntityTypeViewModel()
                    {
                        EntityTypes = entityTypes
                    };

                    model = new CFItem();
                }
            }
            var sytemCollections     = CollectionService.GetSystemCollections();
            var systemCollectionList = new SelectList(sytemCollections.OrderBy(c => c.Name), "Id", "Name");

            ViewBag.SystemCollections = systemCollectionList;
            model.AttachmentField     = new Attachment()
            {
                FileGuids = string.Join(Attachment.FileGuidSeparator.ToString(), model.Files.Select(f => f.Guid))
            };
            return(View(model));
        }
Exemple #4
0
        // GET: Manager/Collections
        public ActionResult Index()
        {
            SecurityService.CreateAccessContext();
            var entities = CollectionService.GetCollections()
                           .Select(e => e as CFEntity);
            var _eTypes = new SelectList(EntityTypeService.GetEntityTypes(CFEntityType.eTarget.Collections).OrderBy(e => e.Name), "Id", "Name");

            ViewBag.EntityTypes = JsonConvert.SerializeObject(_eTypes.ToList());

            return(View(entities));
            //return View();
        }
Exemple #5
0
        // GET: Manager/Collections/Edit/5
        public ActionResult Edit(int?id, int?entityTypeId)
        {
            SecurityService.CreateAccessContext();
            CFCollection model;

            if (id.HasValue && id.Value > 0)
            {
                model = CollectionService.GetCollection(id.Value);
                if (model == null)
                {
                    return(HttpNotFound("Collection was not found"));
                }

                //Sept 27 2019 -- set the READ ONLY
                if (!Catfish.Core.Contexts.AccessContext.current.IsAdmin)//not admin
                {
                    string accessMode = "";
                    foreach (CFAccessGroup ag in model.AccessGroups)
                    {
                        accessMode = ag.AccessDefinition.AccessModes.ToString();
                        if (accessMode == "Read")
                        {
                            ViewBag.ReadOnly = true;
                        }
                        else if (accessMode == "Write")
                        {
                            ViewBag.ReadOnly = false;
                            break;
                        }
                    }
                }
            }
            else
            {
                if (entityTypeId.HasValue)
                {
                    model = CollectionService.CreateCollection(entityTypeId.Value);
                }
                else
                {
                    List <CFEntityType> entityTypes = EntityTypeService.GetEntityTypes(CFEntityType.eTarget.Collections).ToList();
                    ViewBag.SelectEntityViewModel = new SelectEntityTypeViewModel()
                    {
                        EntityTypes = entityTypes
                    };

                    model = new CFCollection();
                }
            }

            return(View(model));
        }
Exemple #6
0
        // GET: Manager/Items/Edit/5
        public ActionResult Edit(int?id, int?entityTypeId)
        {
            CFItem model;

            if (id.HasValue && id.Value > 0)
            {
                model = ItemService.GetItem(id.Value);
                if (model == null)
                {
                    return(HttpNotFound("Item was not found"));
                }
            }
            else
            {
                if (entityTypeId.HasValue)
                {
                    model = ItemService.CreateItem(entityTypeId.Value);
                }
                else
                {
                    List <CFEntityType> entityTypes = EntityTypeService.GetEntityTypes(CFEntityType.eTarget.Items).ToList(); //srv.GetEntityTypes(EntityType.eTarget.Items).ToList();
                    ViewBag.SelectEntityViewModel = new SelectEntityTypeViewModel()
                    {
                        EntityTypes = entityTypes
                    };

                    model = new CFItem();
                }
            }

            model.AttachmentField = new Attachment()
            {
                FileGuids = string.Join(Attachment.FileGuidSeparator.ToString(), model.Files.Select(f => f.Guid))
            };
            return(View(model));
        }
Exemple #7
0
 // GET: Manager/EntityTypes
 public ActionResult Index()
 {
     return(View(EntityTypeService.GetEntityTypes()));
 }