示例#1
0
        public Case GetCaseById(int id)
        {
            Case p = _repository.Get(filter => filter.Id == id).FirstOrDefault();

            if (p != null)
            {
                p.Competance = _competanceRepository.Get(filter => filter.Id == p.CompetanceId).FirstOrDefault();
            }

            return(p);
        }
示例#2
0
        public void AmendCase(Guid commandId, Guid caseId, int revision, string description)
        {
            // Get the case from the repository
            var existingCase = caseRepository.Get(caseId, revision);

            // Change
            existingCase.ChangeDescription(description);

            // Persist
            caseRepository.Store(commandId, existingCase);

            eventBus.Publish(new CaseAmendedEvent(Guid.NewGuid(), commandId, existingCase.Id, existingCase.Revision));
        }
        public async Task <IActionResult> Details(string id)
        {
            // Parse everything till the first '-' as integer into `caseId`
            int.TryParse(id.Split('-', 2)[0], out int caseId);

            var caseItem = await _caseRepository.Get(caseId);

            if (caseItem == null || caseItem.Deleted || !caseItem.Enabled)
            {
                return(NotFound());
            }

            var language = HttpContext?.Features?.Get <IRequestCultureFeature>()?.RequestCulture?.Culture
                           ?.TwoLetterISOLanguageName ?? "nl";

            if (caseItem.Language != language)
            {
                int itemTranslationId;
                itemTranslationId = language == "nl" ?
                                    (await _itemTranslationRepository.GetAllCases()).FirstOrDefault(c => c.IdEn == caseItem.Id).IdNl :
                                    (await _itemTranslationRepository.GetAllCases()).FirstOrDefault(c => c.IdNl == caseItem.Id).IdEn;
                caseItem = await _caseRepository.Get(itemTranslationId);
            }

            if (caseItem == null || caseItem.Deleted || !caseItem.Enabled)
            {
                return(NotFound());
            }

            // Force the right slug
            if (id != caseItem.Slug)
            {
                return(RedirectToAction("Details", new { id = caseItem.Slug }));
            }

            var(previous, next) = await GetAdjacent(caseItem);

            var relatedItems = await _relatedItemsRepository.GetRelatedItems(caseItem.Id, Enumeration.ContentItemType.Case, caseItem.Language);

            return(View(new CaseDetailViewModel
            {
                CaseItem = caseItem,
                ContentItems = relatedItems,
                Next = next,
                Previous = previous
            }));
        }
示例#4
0
        public void CreateHistoricCase(Guid commandId, Guid historicCaseId, Guid caseId, int revision)
        {
            // Get case from repo
            var @case = caseRepository.Get(caseId, revision);

            // Create HistoricCase
            var historicCase = new HistoricCase(Guid.NewGuid(), @case);

            // Persist
            historicCaseRepository.Store(commandId, historicCase);
        }
示例#5
0
        public async Task <IActionResult> Cases(string ids)
        {
            var intIds       = (ids ?? "").Split(",").Where(s => int.TryParse(s.Trim(), out var _)).Select(s => int.Parse(s.Trim())).ToList();
            var currentItems = await _caseRepository.GetHomepageItems("nl");

            var caseItems = new List <Case>();

            for (var i = 0; i < intIds.Count; i++)
            {
                var @case = currentItems.FirstOrDefault(n => n.Id == intIds[i]) ?? await _caseRepository.Get(intIds[i]);

                @case.HomepageOrder = i;
                await _caseRepository.Update(@case);

                caseItems.Add(new Case
                {
                    Id            = @case.Id,
                    Title         = @case.Title,
                    PhotoPath     = @case.PhotoPath,
                    Customer      = @case.Customer,
                    HomepageOrder = @case.HomepageOrder
                });
            }

            foreach (var @case in currentItems.Where(n => !intIds.Contains(n.Id)))
            {
                @case.HomepageOrder = null;
                await _caseRepository.Update(@case);
            }

            foreach (var item in await _caseRepository.GetHomepageItems("en"))
            {
                item.HomepageOrder = null;
                await _caseRepository.Update(item);
            }

            var caseIds         = caseItems.Select(c => c.Id);
            var translatedCases = (await _itemTranslationRepository.GetAllCases())
                                  .Where(i => caseIds.Contains(i.IdNl)).ToDictionary(i => i.IdNl, i => i.IdEn);

            foreach (var translation in translatedCases)
            {
                var translatedCase = await _caseRepository.Get(translation.Value);

                if (translatedCase == null)
                {
                    continue;
                }
                translatedCase.HomepageOrder = caseItems.First(c => c.Id == translation.Key).HomepageOrder;
                await _caseRepository.Update(translatedCase);
            }

            return(View(caseItems));
        }
示例#6
0
        public async Task <Case> Route <TStep>(RouteVariable routeVariable) where TStep : Enum
        {
            //var www = await caseRepository.GetById(caseId);
            var @case = await caseRepository.Get()
                        .Include(a => a.Tracks)
                        .Include(a => a.FlowParameters)
                        .FirstAsync(b => b.Id == routeVariable.CaseId);

            var workFlow    = GetEventInstance <TStep>(@case.WorkFlowReference, @case, routeVariable);
            var currentStep = workFlow.Next();

            @case.Route <TStep>(currentStep);
            caseRepository.Update(@case);
            try
            {
                bpmsUnitOfWork.Commit();
            }
            catch (Exception ex)
            {
                logger.LogError(ex, "CaseRepository");
                throw;
            }
            return(@case);
        }
示例#7
0
 public async Task <IActionResult> TranslationEdit(int id)
 {
     return(View(await _caseRepository.Get(id)));
 }