Exemple #1
0
        public async Task<IActionResult> Edit(int id, [Bind("Id,Price,Address,City,Zip,YearBuilt,PropertyType,SquareFeet,Bedrooms,Bathrooms,GarageCapacity,RelatorName,RelatorPhone,RelatorEmail")] Property @property)
        {
            if (id != @property.Id)
            {
                return NotFound();
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(@property);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PropertyExists(@property.Id))
                    {
                        return NotFound();
                    }
                    else
                    {
                        throw;
                    }
                }
                return RedirectToAction(nameof(Index));
            }
            return View(@property);
        }
Exemple #2
0
 public void Update(T entity)
 {
     if (entity == null)
     {
         throw new ArgumentNullException("entity");
     }
     context.Update(entity);
 }
        public async Task <IActionResult> Update([FromBody] BedType bedType)
        {
            var tmp = await _propertyContext.BedTypes.SingleOrDefaultAsync(b => b.Id == bedType.Id);

            if (tmp == null)
            {
                return(NotFound(new { Message = $"Item with id {bedType.Id} not found." }));
            }
            _propertyContext.Update(bedType);
            await _propertyContext.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetItemById), new { id = bedType.Id }, null));
        }