コード例 #1
0
        public HouseEntity Update(HouseEntity toUpdate)
        {
            HouseEntity single = _context.Houses.FirstOrDefault(x => x.Id == toUpdate.Id);

            if (single == null)
            {
                return null;
            }

            _context.Houses.AddOrUpdate(toUpdate);
            return toUpdate;
        }
コード例 #2
0
        public IHttpActionResult CreateNewHouse(HouseEntity houseEntity)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            HouseEntity addedEntity = _houseRepository.Add(houseEntity);
            _houseRepository.SaveToDb();

            return Created(addedEntity);
        }
コード例 #3
0
 public HouseEntity Add(HouseEntity toAdd)
 {
     _context.Houses.Add(toAdd);
     return toAdd;
 }
コード例 #4
0
        public IHttpActionResult UpdateFullHouse([FromODataUri] int id, HouseEntity houseEntity)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            HouseEntity existingHouseEntity = _houseRepository.GetSingle(id).First();

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

            houseEntity.Id = existingHouseEntity.Id;

            _houseRepository.Update(houseEntity);
            _houseRepository.SaveToDb();

            return StatusCode(HttpStatusCode.NoContent);
        }