public HttpResponseMessage RemoveGuest(int eventID, int guestID)
        {
            var guest = _guestService.GetByID(guestID).Data;

            var user = guest.Host;

            if (user != null && !user.WindowsName.Equals(user.WindowsName))
            {
                return(Request.CreateResponse(HttpStatusCode.Forbidden));
            }

            var ev = _service.GetByID(eventID).Data;

            //guest.HostID = -1;
            //guest.Host = null;

            if (ev != null && ev.GuestsInEvent.Contains(guest))
            {
                //ev.GuestsInEvent.Remove(guest);
                //_service.Update(ev);
                _participantsContext.RemoveGuest(new EventGuestDTO(guest));
                _guestService.Delete(guest);
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Example #2
0
 private void btnGuestDelete_Click(object sender, EventArgs e)
 {
     _guestService.Delete(new Guest {
         Id = Convert.ToInt32(dgvGuests.CurrentRow.Cells[0].Value)
     });
     MessageBox.Show("Konuk Silindi");
     LoadGuests();
 }
Example #3
0
        public async Task <IActionResult> Delete(int guestId)
        {
            var result = await _guestService.Delete(guestId);

            if (result)
            {
                return(Ok());
            }
            return(BadRequest());
        }
Example #4
0
        public HttpResponseMessage Delete(HttpRequestMessage request, int id)
        {
            GuestDTO deletingGuest = guestService.Get(id);

            if (deletingGuest == null)
            {
                return(request.CreateResponse(HttpStatusCode.NotFound));
            }

            guestService.Delete(id);
            return(request.CreateResponse(HttpStatusCode.OK));
        }
Example #5
0
        public HttpResponseMessage Delete(HttpRequestMessage request, int id)
        {
            try
            {
                var guest = service.Get(id);

                if (guest != null)
                {
                    service.Delete(id);
                    return(request.CreateResponse(HttpStatusCode.OK));
                }
                return(request.CreateResponse(HttpStatusCode.NotFound));
            }
            catch (Exception exception)
            {
                return(request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
Example #6
0
        public async Task <IActionResult> Delete(GuestDeleteViewModel model)
        {
            await _guestService.Delete(model.Id);

            return(RedirectToAction(nameof(Index)));
        }
Example #7
0
        public async Task <IActionResult> DeleteGuest(long id)
        {
            await _guestService.Delete(id);

            return(Ok());
        }