Exemplo n.º 1
0
        public IActionResult Create()
        {
            var vModel = new ColumnBlockDTO();

            vModel.ColumnDTOs = new List <ColumnDTO>();
            vModel.ColumnDTOs.Add(new ColumnDTO());
            return(View(vModel));
        }
Exemplo n.º 2
0
        public int Add(ColumnBlockDTO dto)
        {
            var entityModel = ToColumnBlock(dto);

            _dbContext.ColumnBlock.Add(entityModel);
            var result = _dbContext.SaveChanges();

            return(result);
        }
Exemplo n.º 3
0
        public IActionResult Create(ColumnBlockDTO vModel)
        {
            if (ModelState.IsValid)
            {
                _logic.Add(vModel);
                return(RedirectToAction("Index"));
            }

            return(View(vModel));
        }
Exemplo n.º 4
0
        public int Add(ColumnBlockDTO dto)
        {
            for (byte i = 0; i < dto.ColumnDTOs.Count; i++)
            {
                dto.ColumnDTOs[i].ColumnMetaDTO.OrderId = i;
            }

            var result = _repository.Add(dto);

            return(result);
        }
Exemplo n.º 5
0
        private ColumnBlockDTO ToColumnBlockDTO(ColumnBlock columnBlock)
        {
            var result = new ColumnBlockDTO();

            result.Id   = columnBlock.Id;
            result.Name = columnBlock.Name;

            result.ColumnDTOs = columnBlock.ColumnMetas
                                .Select(cm => ToColumnMetaDTO(cm))
                                .ToList();
            return(result);
        }
Exemplo n.º 6
0
        private ColumnBlock ToColumnBlock(ColumnBlockDTO dto)
        {
            var result = new ColumnBlock();

            result.Id   = Guid.NewGuid();
            result.Name = dto.Name;

            result.ColumnMetas = dto.ColumnDTOs
                                 .Select(cm => ToColumnMeta(result.Id, cm))
                                 .ToList();
            return(result);
        }