Пример #1
0
        public async Task <IActionResult> PostPlateTimeRestaurantGoer([FromBody] PlateTimeRestaurantGoer plateTimeRestaurantGoer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.PlateTimeRestaurantGoer.Add(plateTimeRestaurantGoer);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPlateTimeRestaurantGoer", new { id = plateTimeRestaurantGoer.Id }, plateTimeRestaurantGoer));
        }
Пример #2
0
        public void JoinPlateTime(int plateTimeId, int resGoerId)
        {
            PlateTimeRestaurantGoer ptrg = new PlateTimeRestaurantGoer();

            ptrg.PlateTimeId      = plateTimeId;
            ptrg.RestaurantGoerId = resGoerId;

            var exists = GetEntry(plateTimeId, resGoerId);

            if (exists != null)
            {
                return;
            }

            db.Add(ptrg);
            db.SaveChanges();
        }
Пример #3
0
        public async Task <IActionResult> PutPlateTimeRestaurantGoer([FromRoute] int id, [FromBody] PlateTimeRestaurantGoer plateTimeRestaurantGoer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != plateTimeRestaurantGoer.Id)
            {
                return(BadRequest());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PlateTimeRestaurantGoerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }