Exemple #1
0
        // GET api/<controller>/5


        // POST api/<controller>
        public void UpdateProtocol(SubmitRequest p)
        {
            try
            {
                if (p.Action == "addprotocol")  //new protocol
                {
                    if (!new Data.ProtocolsData().ProtocolNameExists(p.ProtocolName))
                    {
                        new Data.ProtocolsData().AddProtocol(decimal.Parse(p.ProtocolGroupCKey), p.ProtocolVersion, decimal.Parse(p.UserCkey), p.ProtocolName, decimal.Parse(p.CloneChecklistCKey));
                    }
                    else
                    {
                        var resp = new HttpResponseMessage(HttpStatusCode.ExpectationFailed)

                        {
                            ReasonPhrase = "Protocol Name: " + p.ProtocolName + " already exists. Please select a differeent name."
                        };

                        throw new HttpResponseException(resp);
                    }
                }

                else if (p.Action == "addversion")  //new version
                {
                    if (!new Data.ProtocolsData().ProtocolVersionExists(decimal.Parse(p.ProtocolCKey), p.ProtocolVersion))
                    {
                        new Data.ProtocolsData().AddProtocol(decimal.Parse(p.ProtocolGroupCKey), p.ProtocolVersion, decimal.Parse(p.UserCkey), p.ProtocolName, decimal.Parse(p.CloneChecklistCKey));
                    }
                }
                else if (p.Action == "update") //update
                {
                    //rename version/protocolname
                    new Data.ProtocolsData().UpdateProtocolName(decimal.Parse(p.ProtocolCKey), p.ProtocolName);
                    new Data.ProtocolsData().UpdateProtocolVersion(decimal.Parse(p.ProtocolVersionCKey), p.ProtocolVersion);
                }
                else if (p.Action == "deleteprotocol")
                {
                    new Data.ProtocolsData().DeleteProtocol(decimal.Parse(p.ProtocolCKey));
                }
            }
            catch (Exception ex)
            {
                var resp = new HttpResponseMessage(HttpStatusCode.ExpectationFailed)

                {
                    ReasonPhrase = ex.Message
                };

                throw new HttpResponseException(resp);
            }
        }
Exemple #2
0
        // GET api/<controller>
        public List <SubmitRequest> Get()
        {
            DataTable            dt        = ProtocolsData.GetProtocols();
            List <SubmitRequest> protocols = new List <SubmitRequest>();

            foreach (DataRow dr in dt.Rows)
            {
                SubmitRequest p = new SubmitRequest();
                p.ProtocolCKey = dr["protocolckey"].ToString();
                p.ProtocolName = dr["protocolname"].ToString();
                protocols.Add(p);
            }
            return(protocols);
        }
Exemple #3
0
        public List <SubmitRequest> GetProtocolsByGroup(string ProtocolGroup)
        {
            DataTable            dt        = ProtocolsData.GetProtocolsTableData(decimal.Parse(ProtocolGroup));;
            List <SubmitRequest> protocols = new List <SubmitRequest>();
            SubmitRequest        p         = new SubmitRequest();

            foreach (DataRow dr in dt.Rows)
            {
                p = new SubmitRequest();
                p.ProtocolCKey = dr["protocolckey"].ToString();
                p.ProtocolName = dr["protocolname"].ToString();
                protocols.Add(p);
            }
            p = new SubmitRequest();
            p.ProtocolName = "--New Protocol--";
            p.ProtocolCKey = "0";
            protocols.Add(p);
            return(protocols);
        }