示例#1
0
        public IActionResult Create(CollectionCreateModel model)
        {
            Collection collection = CreateCollectionFromModel(model);

            collection.SelectedFieldsMask = CreateMaskOfSelectedFields(model.AdditionalFields);
            SetCollectionImageInBytes(model.Image, collection);
            dbManager.AddCollection(collection);
            return(RedirectToAction("Index"));
        }
示例#2
0
 public Collection CreateCollectionFromModel(CollectionCreateModel model)
 {
     return(new Collection
     {
         ShortDescription = model.ShortDescription,
         ThemeId = (byte)model.CollectionTheme,
         AdditionalItemsFields = string.Join(",", model.AdditionalFields),
         UserId = User.FindFirstValue(ClaimTypes.NameIdentifier)
     });
 }
示例#3
0
    public async void ModifyCollection_AddInto_MovesCollection()
    {
        var client = _fileSystemFixture.CreateMockClientWithResponse("Collections.json");

        var expected = new CollectionCreateModel
        {
            Codename   = "second_collection",
            ExternalId = "second_external_id",
            Name       = "Second collection"
        };

        var change = new CollectionAddIntoPatchModel {
            Value = expected, After = Reference.ById(Guid.Empty)
        };

        var response = await client.ModifyCollectionAsync(new[] { change });

        response.Collections.Should().ContainEquivalentOf(expected);
    }
        public async Task <IActionResult> CreateCollection([FromBody] CollectionCreateModel model)
        {
            var accid = AuthMan.GetAccountId(this);
            var t     = new T();
            var colls = await _Repository._DbContext.Collections.Where(x => x.Creator == accid && x.Type == t.GetType().Name&& x.TargetId == model.TargetId).ToListAsync();

            if (colls.Count > 0)
            {
                return(Ok());
            }

            var mapping = new Func <Collection, Task <Collection> >(async(entity) =>
            {
                entity.TargetId = model.TargetId;
                entity.Type     = t.GetType().Name;
                return(await Task.FromResult(entity));
            });

            return(await _PostCollectionRequest(mapping));
        }