コード例 #1
0
        public async Task <IActionResult> PutProperty([FromBody] Property @property)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                _context.Entry(@property).State = EntityState.Modified;
                Console.WriteLine("State change, yet to save.");
                await _context.SaveChangesAsync();

                Console.WriteLine("Saved.");
            }
            catch (DbUpdateConcurrencyException ex)
            {
                if (!PropertyExists(@property.PropId))
                {
                    return(NotFound());
                }
                else
                {
                    Console.WriteLine("Error updating: " + ex);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                Log.Error(string.Format("PutProperty error ", @property), ex);
                return(BadRequest());
            }

            return(NoContent());
        }
コード例 #2
0
        public async Task <IActionResult> Update([FromRoute] string email, [FromBody] AccBooking booking)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                _context.Entry(booking).State = EntityState.Modified;
                Console.WriteLine("State change, yet to save.");
                await _context.SaveChangesAsync();

                Console.WriteLine("Saved.");
            }
            catch (DbUpdateConcurrencyException ex)
            {
                if (!BookingExists(booking.UserId))
                {
                    return(NotFound());
                }
                else
                {
                    Console.WriteLine("Error updating: " + ex);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            return(NoContent());
        }
コード例 #3
0
        public async Task <IActionResult> PutAccDetail([FromRoute] int id, [FromBody] AccDetail accDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != accDetail.DetailId)
            {
                return(BadRequest());
            }

            _context.Entry(accDetail).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AccDetailExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(BadRequest());
            }

            return(NoContent());
        }