private bool IsValidData(CCIRPIR cCIRPIR, out string message) { message = string.Empty; if (!IsValidCountry(cCIRPIR.CountryId)) { message = "Invalid Country Id:" + cCIRPIR.CountryId; } if (!IsValidBranch(cCIRPIR.BranchId)) { message = "Invalid Branch Id:" + cCIRPIR.BranchId; } if (!IsValidCOCOM(cCIRPIR.COCOMId)) { message = "Invalid COCOM Id:" + cCIRPIR.COCOMId; } if (!IsValidCommander(cCIRPIR.CommanderId)) { message = "Invalid Commander Id:" + cCIRPIR.CommanderId; } if (!IsValidRegion(cCIRPIR.RegionId)) { message = "Invalid Region Id:" + cCIRPIR.RegionId; } if (!IsValidUnit(cCIRPIR.UnitId)) { message = "Invalid Unit Id:" + cCIRPIR.UnitId; } return(message == string.Empty); }
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)); }
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)); }
public IHttpActionResult GetCCIRPIR(string id) { CCIRPIR cCIRs = db.CCIRPIRs.Find(id); if (cCIRs == null) { return(NotFound()); } return(Ok(new DropDownDTO { id = cCIRs.CCIRPIRId.ToString(), description = cCIRs.Description1 })); }
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)); }
public async Task <IHttpActionResult> PostCCIRPIR() { 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); //} cCIRPIR.CCIRPIRId = Guid.NewGuid().ToString(); cCIRPIR.CreationDateTime = cCIRPIR.LastUpdate = DateTime.Now; db.CCIRPIRs.Add(cCIRPIR); db.SaveChanges(); return(CreatedAtRoute("DefaultApiPost", new { id = cCIRPIR.CCIRPIRId }, cCIRPIR)); }