public async Task <ActionResult> AddSponsorAsync(int id, EventSponsorInsertRequest request) { var response = await _service.AddSponsor(id, request); if (!response) { var errorModel = new ErrorModel() { Message = "Sponsor is already added to the Event" }; var error = new ErrorResponse(errorModel); return(Conflict(error)); } return(Ok()); }
public async Task <bool> AddSponsor(int eventId, EventSponsorInsertRequest request) { var entity = new EventSponsor { EventID = eventId, SponsorID = request.SponsorID, SponsorCategory = request.SponsorCategory }; try { await _context.EventSponsors.AddAsync(entity); await _context.SaveChangesAsync(); return(true); } catch { return(false); } }