Esempio n. 1
0
        public IActionResult Put(int id, [FromBody] Siparis value)
        {
            if (value == null)
            {
                return(BadRequest());
            }

            var note = _sR.GetById(id);


            if (note == null)
            {
                return(NotFound());
            }

            value.Id = id;
            _sR.Update(value);


            return(NoContent());
        }
Esempio n. 2
0
        public async Task <SiparisResponse> UpdateAsync(int id, Siparis siparis)
        {
            var existingSiparis = await _siparisRepository.FindByIdAsync(id);

            if (existingSiparis == null)
            {
                return(new SiparisResponse("Siparis not found."));
            }

            existingSiparis.SiparisId = siparis.SiparisId;

            try
            {
                _siparisRepository.Update(existingSiparis);
                await _unitOfWork.CompleteAsync();

                return(new SiparisResponse(existingSiparis));
            }
            catch (Exception ex)
            {
                // Do some logging stuff
                return(new SiparisResponse($"An error occurred when updating the siparis: {ex.Message}"));
            }
        }