Exemple #1
0
        public IActionResult Update(int id, [FromBody] Takvimler newdata)
        {
            var olddata = _appRepository.GetTakvimlerById(id);

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

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

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

            var res = _appRepository.SaveAll();

            if (res.OK)
            {
                return(Ok(olddata));
            }
            else
            {
                return(BadRequest(id + " başarısız?! " + res.ERR));
            }
        }
Exemple #2
0
        public IActionResult Add([FromBody] Takvimler newdata)
        {
            if (newdata == null)
            {
                return(Ok(_ControllersHelper.notfound("data is null")));
            }

            _appRepository.Add(newdata); ////////////////////////////////////////

            var res = _appRepository.SaveAll();

            if (res.OK)
            {
                return(Ok(newdata));
            }
            else
            {
                return(BadRequest("başarısız?! " + res.ERR));
            }
        }