Esempio n. 1
0
        public ActionResult Event(int sourceId, int targetId)
        {
            Source source = this.sourceTasks.GetSource(sourceId);

            if (source != null)
            {
                Profiling2.Domain.Prf.Events.Event ev = this.eventTasks.GetEvent(targetId);
                if (ev != null)
                {
                    EventSourceViewModel vm = new EventSourceViewModel();
                    vm.SourceId = source.Id;
                    vm.EventId  = ev.Id;
                    vm.PopulateDropDowns(this.sourceTasks.GetReliabilities());

                    ViewBag.Event  = ev;
                    ViewBag.Source = source;

                    EventSource es = source.GetEventSource(ev);
                    if (es != null)
                    {
                        // Event is already attached to Source
                        vm.Id         = es.Id;
                        vm.Commentary = es.Commentary;
                        vm.Notes      = es.Notes;
                    }

                    return(View(vm));
                }
            }
            return(new HttpNotFoundResult());
        }
        public ActionResult Add(int eventId)
        {
            Event e = this.eventTasks.GetEvent(eventId);

            if (e != null)
            {
                EventSourceViewModel esvm = new EventSourceViewModel(e);
                esvm.PopulateDropDowns(this.sourceTasks.GetReliabilities());
                return(View(esvm));
            }
            return(new HttpNotFoundResult());
        }
        public ActionResult Edit(int id)
        {
            EventSource es = this.sourceAttachmentTasks.GetEventSource(id);

            if (es != null)
            {
                EventSourceViewModel vm = new EventSourceViewModel(es);
                vm.PopulateDropDowns(this.sourceTasks.GetReliabilities());

                // get SourceDTO in order to not load Source entity
                vm.PopulateSource(this.sourceTasks.GetSourceDTO(es.Source.Id));

                return(View(vm));
            }
            return(new HttpNotFoundResult());
        }
 public JsonNetResult Add(EventSourceViewModel vm)
 {
     if (ModelState.IsValid)
     {
         Source source = this.sourceTasks.GetSource(vm.SourceId.Value);
         Event  ev     = this.eventTasks.GetEvent(vm.EventId.Value);
         if (source != null && ev != null)
         {
             if (source.GetEventSource(ev) == null)
             {
                 EventSource es = new EventSource();
                 es.Source = source;
                 es.Event  = ev;
                 if (vm.ReliabilityId.HasValue)
                 {
                     es.Reliability = this.sourceTasks.GetReliability(vm.ReliabilityId.Value);
                 }
                 es.Commentary = vm.Commentary;
                 es.Notes      = vm.Notes;
                 this.sourceAttachmentTasks.SaveEventSource(es);
                 return(JsonNet(string.Empty));
             }
             else
             {
                 Response.StatusCode = (int)HttpStatusCode.BadRequest;
                 return(JsonNet("Source already attached to this event."));
             }
         }
         else
         {
             Response.StatusCode = (int)HttpStatusCode.NotFound;
             return(JsonNet("Event or source not found."));
         }
     }
     else
     {
         return(JsonNet(this.GetErrorsForJson()));
     }
 }
Esempio n. 5
0
 // TODO this detaches the event if POSTed an EventSource.Id.  Function replicated in EventSourcesController.
 public JsonNetResult Event(EventSourceViewModel vm)
 {
     if (vm.Id.HasValue)
     {
         this.sourceAttachmentTasks.DeleteEventSource(vm.Id.Value);
         Response.StatusCode = (int)HttpStatusCode.OK;
         return(JsonNet("Event successfully detached from source."));
     }
     else if (ModelState.IsValid)
     {
         Source source = this.sourceTasks.GetSource(vm.SourceId.Value);
         Profiling2.Domain.Prf.Events.Event ev = this.eventTasks.GetEvent(vm.EventId.Value);
         if (source != null && ev != null)
         {
             if (source.GetEventSource(ev) == null)
             {
                 EventSource es = new EventSource();
                 es.Source      = source;
                 es.Event       = ev;
                 es.Reliability = this.sourceTasks.GetReliability(vm.ReliabilityId.Value);
                 es.Commentary  = vm.Commentary;
                 es.Notes       = vm.Notes;
                 this.sourceAttachmentTasks.SaveEventSource(es);
             }
             Response.StatusCode = (int)HttpStatusCode.OK;
             return(JsonNet("Event successfully attached."));
         }
         else
         {
             Response.StatusCode = (int)HttpStatusCode.NotFound;
             return(JsonNet("Event or source not found."));
         }
     }
     else
     {
         Response.StatusCode = (int)HttpStatusCode.BadRequest;
         return(JsonNet("Form failed validation."));
     }
 }
 public JsonNetResult Edit(EventSourceViewModel vm)
 {
     if (ModelState.IsValid && vm.Id.HasValue)
     {
         EventSource es = this.sourceAttachmentTasks.GetEventSource(vm.Id.Value);
         if (es != null)
         {
             if (vm.ReliabilityId.HasValue)
             {
                 es.Reliability = this.sourceTasks.GetReliability(vm.ReliabilityId.Value);
             }
             es.Commentary = vm.Commentary;
             es.Notes      = vm.Notes;
             return(JsonNet(string.Empty));
         }
         Response.StatusCode = (int)HttpStatusCode.NotFound;
         return(JsonNet("Event source does not exist."));
     }
     else
     {
         return(JsonNet(this.GetErrorsForJson()));
     }
 }
Esempio n. 7
0
 public EventAggregationViewModel(IEventAggregator eventAggregator)
 {
     Source      = new EventSourceViewModel(eventAggregator);
     Destination = new EventDestinationViewModel(eventAggregator);
 }