public async Task <ActionResult> CreateEdit(mstSubRegion myData) { if (myData.IdSubRegion > 0) { HttpResponseMessage responseMessage = await client.PutAsJsonAsync(url + "/" + myData.IdSubRegion.ToString(), myData); if (responseMessage.IsSuccessStatusCode) { return(RedirectToAction("Index")); } return(RedirectToAction("Error")); } else { myData.CreatedDate = DateTime.Today; myData.CreatedUser = "******"; HttpResponseMessage responseMessage = await client.PostAsJsonAsync(url, myData); if (responseMessage.IsSuccessStatusCode) { return(RedirectToAction("Index")); } return(RedirectToAction("Error")); } }
//The DELETE method public async Task <ActionResult> Delete(int IdData, mstSubRegion Emp) { HttpResponseMessage responseMessage = await client.DeleteAsync(url + "/" + IdData); if (responseMessage.IsSuccessStatusCode) { return(RedirectToAction("Index")); } return(RedirectToAction("Error")); }
public IHttpActionResult Get(int id) { mstSubRegionForm myDataForm = new mstSubRegionForm(); mstSubRegion myData = new mstSubRegion(); myData = _repository.Get(id); if (myData != null) { myDataForm.InjectFrom(myData); myDataForm.RegionColls = _repRegion.Get(); } else { myDataForm.RegionColls = _repRegion.Get(); } return(Ok(myDataForm)); }
public IHttpActionResult Put(int id, mstSubRegion myData) { _repository.Put(id, myData); return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult Post(mstSubRegion myData) { _repository.Post(myData); return(Ok(myData)); }