Exemple #1
0
        public ActionResult Post([FromBody] Siri siri)
        {
            if (!this.ModelState.IsValid || siri == null)
            {
                return(BadRequest());
            }
            else
            {
                var maxExistingId = 0;
                if (Repository.Siris.Count > 0)
                {
                    maxExistingId = Repository.Siris.Keys.Max();
                }
                //                siri.ID = maxExistingId + 1;
                Repository.Siris.Add(maxExistingId + 1, siri);

                SiriServiceInformation serviceInfo = new SiriServiceInformation();
                serviceInfo.ServiceStartTime = _info.ServiceStartTime;

                SiriManager sm = new SiriManager(siri, serviceInfo);
                sm.process();
                switch (sm.status)
                {
                case SiriManager.Status.ValidAndResponse:
                    return(Ok(sm.response));

                case SiriManager.Status.ValidNoResponse:
                    return(Accepted());

                case SiriManager.Status.ValidNotSupport:
                    return(UnprocessableEntity());

                default:
                    return(BadRequest());
                }
            }
        }
 public SiriManager(Siri siriInput, SiriServiceInformation serviceInfoInput)
 {
     this.siri = siriInput;
     this.serviceInfo = serviceInfoInput;
 }