Esempio n. 1
0
        public IActionResult PostShadow(DrcCardViewModel drcCardViewModel)
        {
            var shadowCard = _mapper.Map <DrcCard>(drcCardViewModel);

            shadowCard.MainCardId = shadowCard.Id;
            shadowCard.Id         = 0;
            if (!TryValidateModel(shadowCard))
            {
                ViewData["Message"]            = "model is not valid";
                ViewData["SubdomainVersionId"] = shadowCard.SubdomainVersionId;

                return(View("ErrorPage"));
            }


            var result = _drcCardService.AddShadowCard(shadowCard);

            if (String.IsNullOrEmpty(result))
            {
                return(Redirect("/DrcCards/index?id=" + shadowCard.SubdomainVersionId));
            }
            else
            {
                ViewData["Message"]            = result;
                ViewData["SubdomainVersionId"] = shadowCard.SubdomainVersionId;

                return(View("ErrorPage"));
            }
        }
Esempio n. 2
0
        public IActionResult Post(DrcCardViewModel drcCardViewModel)
        {
            var newDrcCard = _mapper.Map <DrcCardBusinessModel>(drcCardViewModel);

            _drcCardService.Add(newDrcCard);


            return(Redirect("/DrcCards/index?id=" + drcCardViewModel.SubdomainVersionId));
        }
Esempio n. 3
0
        public async Task <object> Presentation(string searchText)
        {
            String querySubdomain = HttpContext.Request.Query["subdomain"];
            String queryVersion   = HttpContext.Request.Query["version"];

            DrcCardContainerViewModel drcCardContainerViewModel = new DrcCardContainerViewModel();
            int id = _drcCardService.getVersionIdFromQueryString(querySubdomain, queryVersion);

            if (id > 0)
            {
                if (id != 0)
                {
                    var tempCards = await _drcCardService.GetAllDrcCards(id);

                    foreach (var card in tempCards)
                    {
                        DrcCardViewModel drcCardViewModel = _mapper.Map <DrcCardViewModel>(card);


                        foreach (var responsibilityBusinessModel in _drcCardService.getListOfDrcCardResponsibilities(card.Id))
                        {
                            drcCardViewModel.Responsibilities.Add(_mapper.Map <ResponsibilityViewModel>(responsibilityBusinessModel));
                        }


                        foreach (var fieldBusinessModel in _drcCardService.getListOfDrcCardFields(card.Id, card.MainCardId))
                        {
                            drcCardViewModel.Fields.Add(_mapper.Map <FieldViewModel>(fieldBusinessModel));
                        }


                        foreach (var authorizationBusinessModel in _drcCardService.getListOfDrcCardAuthorizations(card.Id))
                        {
                            drcCardViewModel.Authorizations.Add(_mapper.Map <AuthorizationViewModel>(authorizationBusinessModel));
                        }

                        drcCardViewModel.SourceDrcCardPath = _drcCardService.GetShadowCardSourcePath(card.MainCardId);
                        drcCardContainerViewModel.DrcCardViewModes.Add(drcCardViewModel);
                    }

                    drcCardContainerViewModel.PresentationHeader = _drcCardService.GetPresentationHeader(id);
                    drcCardContainerViewModel.DrcCardViewModel.SubdomainVersionId = id;
                }
                return(View(drcCardContainerViewModel));
            }

            drcCardContainerViewModel.ErrorMessage = "The address you entered is not available";

            return(View(drcCardContainerViewModel));
        }
Esempio n. 4
0
        public async Task <IActionResult> Delete([FromBody] DrcCardViewModel model)
        {
            string IsdocumentUsedAsCollaboration = _drcCardMoveService.checkIfDocumentConnectedToCurrentVersion(model.Id);

            if (String.IsNullOrEmpty(IsdocumentUsedAsCollaboration))
            {
                string result = await _drcCardService.Delete(model.Id);

                if (string.IsNullOrEmpty(result))
                {
                    return(Ok());
                }
                else
                {
                    return(BadRequest("Please delete the shadows of this document. You have fallowing shadows of this document; " + result));
                }
            }
            else
            {
                return(BadRequest("To be able to delete this document you must first delete relations with fallowing documents: " + IsdocumentUsedAsCollaboration));
            }
        }
Esempio n. 5
0
        public async Task <IActionResult> MoveCardToDestinationSubdomain([FromBody] DrcCardViewModel drcCardViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var checkReferences = await _drcCardMoveService.CheckMoveOperationReferenceNeeds(drcCardViewModel.Id, drcCardViewModel.SubdomainVersionId);

                    if (string.IsNullOrWhiteSpace(checkReferences))
                    {
                        var result = await _drcCardMoveService.MoveCardToDestinationSubdomainAsync(drcCardViewModel.Id, drcCardViewModel.SubdomainVersionId, drcCardViewModel.DrcCardName);

                        if (result.MoveResultType == MoveResultType.Success)
                        {
                            return(Ok(result));
                        }
                        else
                        {
                            return(BadRequest(result.MoveResultDefinition));
                        }
                    }
                    else
                    {
                        return(BadRequest(checkReferences));
                    }
                }
                else
                {
                    return(BadRequest("I will add error to here"));
                }
            }
            catch (Exception e)
            {
                ViewData["Message"]            = e.Message;
                ViewData["SubdomainVersionId"] = 0;
                return(View("ErrorPage"));
            }
        }