コード例 #1
0
        public async Task <IActionResult> PutEventCaseDefinition(Guid id, EventCaseDefinition eventCaseDefinition)
        {
            if (id != eventCaseDefinition.UidCase)
            {
                return(BadRequest());
            }

            _context.Entry(eventCaseDefinition).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EventCaseDefinitionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #2
0
        /// <summary>
        /// Gets the <see cref="SwitchCaseDefinition"/> with the specified name
        /// </summary>
        /// <param name="state">The <see cref="SwitchStateDefinition"/> to search for the <see cref="SwitchCaseDefinition"/> with the specified name</param>
        /// <param name="caseName">The name of the <see cref="SwitchCaseDefinition"/> to get</param>
        /// <returns>The <see cref="SwitchCaseDefinition"/> with the specified name</returns>
        public static SwitchCaseDefinition?GetCase(this SwitchStateDefinition state, string caseName)
        {
            SwitchCaseDefinition @case;

            switch (state.SwitchType)
            {
            case SwitchStateType.Data:
                if (caseName == "default")
                {
                    @case = new DataCaseDefinition()
                    {
                        Name = "default", Transition = state.DefaultCondition.Transition, End = state.DefaultCondition.End
                    }
                }
                ;
                else
                {
                    @case = state.DataConditions.Single(c => c.Name == caseName);
                }
                break;

            case SwitchStateType.Event:
                if (caseName == "default")
                {
                    @case = new EventCaseDefinition()
                    {
                        Name = "default", Transition = state.DefaultCondition.Transition, End = state.DefaultCondition.End
                    }
                }
                ;
                else
                {
                    @case = state.EventConditions.Single(c => c.Name == caseName);
                }
                break;

            default:
                throw new NotSupportedException($"The specified switch state type '{state.SwitchType}' is not supported in this context");
            }
            return(@case);
        }
コード例 #3
0
 /// <summary>
 /// Attempts to get the <see cref="EventCaseDefinition"/> that applies to the specified event
 /// </summary>
 /// <param name="state">The <see cref="SwitchStateDefinition"/> to search for the specified <see cref="EventCaseDefinition"/></param>
 /// <param name="eventReference">The reference of the event the <see cref="EventCaseDefinition"/> to get applies to</param>
 /// <param name="case">The <see cref="EventCaseDefinition"/> that applies to the specified event</param>
 /// <returns>A boolean indicating whether or not a <see cref="EventCaseDefinition"/> with the specified id could be found</returns>
 public static bool TryGetEventCondition(this SwitchStateDefinition state, string eventReference, out EventCaseDefinition @case)
 {
     @case = null !;
     try
     {
         @case = state.GetEventCondition(eventReference) !;
     }
     catch
     {
         return(false);
     }
     return(@case != null);
 }
コード例 #4
0
        public async Task <ActionResult <EventCaseDefinition> > PostEventCaseDefinition(EventCaseDefinition eventCaseDefinition)
        {
            _context.EventCaseDefinition.Add(eventCaseDefinition);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (EventCaseDefinitionExists(eventCaseDefinition.UidCase))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetEventCaseDefinition", new { id = eventCaseDefinition.UidCase }, eventCaseDefinition));
        }