コード例 #1
0
        [Route("detail")]      // /detail?Id=123
        public ActionResult Get(ClsDers id)
        {
            var data = _appRepository.GetDersDetayById(id);      ////////////////////////////////////////

            var dataToReturn = _mapper.Map <ClsDersDetay>(data); // CityForDetailDto

            if (dataToReturn == null)
            {
                return(Ok(_ControllersHelper.notfound(info: id)));
            }

            return(Ok(_ControllersHelper.fixarray(dataToReturn)));
        }
コード例 #2
0
        [Route("delete/{id}")] // böyle daha açık
        public ActionResult Delete(ClsDers id)
        {
            var data = _appRepository.GetDersDetayById(id);

            if (data == null)
            {
                return(Ok(_ControllersHelper.notfound(info: id)));
            }

            _appRepository.Delete(data); ////////////////////////////////////////

            if (_appRepository.SaveAll())
            {
                return(Ok(data));
            }
            else
            {
                return(BadRequest(id + " başarısız?!"));
            }
        }
コード例 #3
0
        public ActionResult Update(ClsDers id, [FromBody] ClsDersDetay newdata)
        {
            var olddata = _appRepository.GetDersDetayById(id);

            if (olddata == null)
            {
                return(Ok(_ControllersHelper.notfound(info: id)));
            }

            // _ControllersHelper.PrepareUpdate(typeof(ClsDersDetay), olddata, newdata);
            _ControllersHelper.PrepareUpdate(newdata.GetType(), olddata, newdata);
            // ikiside olur

            _appRepository.Update(olddata); ////////////////////////////////////////

            if (_appRepository.SaveAll())
            {
                return(Ok(olddata));
            }
            else
            {
                return(BadRequest(id + " başarısız?!"));
            }
        }