コード例 #1
0
        public IHttpActionResult DeleteCCIRPIR(string id)
        {
            CCIRPIR cCIRs = db.CCIRPIRs.Find(id);

            if (cCIRs == null)
            {
                return(NotFound());
            }

            db.CCIRPIRs.Remove(cCIRs);
            db.SaveChanges();
            cCIRs.DeleteFiles(cCIRs.GetType().GetProperties().Where(p => properties.Contains(p.Name)).ToArray(), "CCIRPIR");
            return(Ok(cCIRs));
        }
コード例 #2
0
        public IHttpActionResult GetCCIRPIRData(string id)
        {
            CCIRPIR cCIRs = db.CCIRPIRs.Find(id);

            if (cCIRs == null)
            {
                return(NotFound());
            }

            cCIRs.AddUrl(cCIRs.GetType().GetProperties().Where(p => properties.Contains(p.Name)).ToArray(), this.Request);
            //object uploadUrl;
            //Request.Properties.TryGetValue("uploadUrl", out uploadUrl);
            //cCIRs.EffectiveAreaKML = uploadUrl + cCIRs.EffectiveAreaKML;
            return(Ok(cCIRs));
        }
コード例 #3
0
        public async Task <IHttpActionResult> PutCCIRPIR(string id)
        {
            CCIRPIR cCIRPIR = await UpdateDataWithFile();

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            // TODO It can make api slow so commenting it. Will use if needed
            //string message = string.Empty;
            //if (!IsValidData(cCIRs, out message))
            //{
            //    return BadRequest(message);
            //}

            if (!string.Equals(cCIRPIR.CCIRPIRId, id.ToString(), StringComparison.OrdinalIgnoreCase))
            {
                return(BadRequest());
            }

            cCIRPIR.RemoveUrl(cCIRPIR.GetType().GetProperties().Where(p => properties.Contains(p.Name)).ToArray(), this.Request);
            cCIRPIR.LastUpdate      = DateTime.Now;
            db.Entry(cCIRPIR).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CCIRPIRsExists(id.ToString()))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }