コード例 #1
0
        public async Task <CategoryResponse> Add(CategoryAddRequest request)
        {
            var categoryToAdd = request.Model.MapToModel();

            categoryToAdd.FieldDefenitions?.Clear();
            categoryToAdd.FieldDefenitionGroups?.Clear();
            await BaseBeforeAddAsync(categoryToAdd, request.RequestOwner);

            await _dataSrv.AddAsync(categoryToAdd);

            request.Model.FieldDefenitions.ToList().MapToModel().ForEach(x =>
            {
                x.CategoryId = categoryToAdd.Id;
                _fieldDefentionFacade.PendToAdd(x);
            });
            request.Model.FieldDefenitionGroups.ToList().MapToModel().ForEach(x =>
            {
                x.CategoryId = categoryToAdd.Id;
                _unitOfWork.Add(x);
            });
            await _fieldDefentionFacade.SaveChangesAsync();

            await BaseAfterAddAsync(categoryToAdd, request.RequestOwner);

            HandleMetaData(request.Model.MetaData, categoryToAdd);
            await _unitOfWork.SaveChangesAsync();

            return(new CategoryResponse()
            {
                Access = ResponseAccess.Granted,
                Category = categoryToAdd.MapToViewModel()
            });
        }
コード例 #2
0
        public async Task <IHttpActionResult> Post(FieldDefenitionAddOrUpdateModel model)
        {
            var fd = model.MapToModel();

            _fieldDefentionFacade.PendToAdd(fd);
            await _fieldDefentionFacade.SaveChangesAsync();

            return(Ok(fd));
        }