コード例 #1
0
        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"));
            }
        }
コード例 #2
0
        //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"));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
 public IHttpActionResult Put(int id, mstSubRegion myData)
 {
     _repository.Put(id, myData);
     return(StatusCode(HttpStatusCode.NoContent));
 }
コード例 #5
0
 public IHttpActionResult Post(mstSubRegion myData)
 {
     _repository.Post(myData);
     return(Ok(myData));
 }