Esempio n. 1
0
        public IHttpActionResult Patch([FromODataUri] string key, Delta <NURSE_CONSULTATIONEntity> patch)
        {
            NURSE_CONSULTATIONService service = new NURSE_CONSULTATIONService();
            object id;

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            else if (patch.GetChangedPropertyNames().Contains("ID") && patch.TryGetPropertyValue("ID", out id) && (string)id != key)
            {
                return(BadRequest("The key from the url must match the key of the entity in the body"));
            }

            try
            {
                var query = service.GetEntity(key);
                patch.Patch(query);
                service.UpdateEntity(query);
                return(Updated(query));
            }
            catch (Exception)
            {
                return(NotFound());
            }
        }
Esempio n. 2
0
        public IHttpActionResult RecordQuery(string key)
        {
            NURSE_CONSULTATIONService service = new NURSE_CONSULTATIONService();

            try
            {
                var query         = service.GetEntity(key);
                var packageEntity = query.PackageResult();
                return(Json(packageEntity));
            }
            catch (Exception)
            {
                PackageResultEntity <object> packageResultEntity = new PackageResultEntity <object>()
                {
                    list = null,
                    msg  = "failed"
                };
                return(Json(packageResultEntity));
            }
        }