Beispiel #1
0
        public async Task <IActionResult> Add(DocumentTypeCreateDto documentTypeDto)
        {
            DocumentType docType = mapper.Map <DocumentType>(documentTypeDto);

            await documentTypeService.Create(docType);

            return(NoContent());
        }
Beispiel #2
0
        public DocumentTypeDetailDto AddDocumentType(DocumentTypeCreateDto dto)
        {
            var entity = AutoMapper.Mapper.Map <DocumentType>(dto);

            var newEntity = _docTypeRepository.Add(entity);

            return(AutoMapper.Mapper.Map <DocumentTypeDetailDto>(newEntity));
        }
        public async Task <IActionResult> Create([Bind("Description,Expires,ExpiryDate")] DocumentTypeCreateDto documentType)
        {
            if (ModelState.IsValid)
            {
                if (User.IsInRole("Owner"))
                {
                    var user = await _userManager.FindByNameAsync(User.Identity.Name);

                    documentType.Owner = user;
                }
                // Check role...if they are an owner....its custom document type..

                documentType.Id = Guid.NewGuid();
                var mappedData = _mapper.Map <DocumentType>(documentType);
                _context.Add(mappedData);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(documentType));
        }