public IActionResult Add(int conferenceId) { ViewBag.Title = "Add Proposal"; return(View(proposalService.Add(new ProposalModel { ConferenceId = conferenceId }))); }
public async Task <IActionResult> Add(ProposalModel proposal) { if (ModelState.IsValid) { await proposalService.Add(proposal); } return(RedirectToAction("Index", new { conferenceId = proposal.ConferenceId })); }
public async Task <IActionResult> Add(ProposalModel model) { if (ModelState.IsValid) { await proposalService.Add(model); } return(RedirectToAction("Index", new { conferenceId = protector.Protect(model.ConferenceId.ToString()) })); }
public IActionResult Add(Proposal proposal) { var result = _proposalService.Add(proposal); if (result.Success) { return(Ok(result.Message)); } return(BadRequest(result.Message)); }
public IActionResult Post([FromBody] Proposal model) { if (ModelState.IsValid) { _proposalService.Add(model); return(new CreatedAtRouteResult("GetByIdProposal", new { id = model.Id }, model)); } else { return(BadRequest("Some fields are empty")); } }
public async Task <IActionResult> OnPost(int conferenceId) { Proposal.ConferenceId = conferenceId; if (!ModelState.IsValid) { return(Page()); } await proposalService.Add(Proposal); return(RedirectToPage("ProposalList", new { conferenceId = conferenceId })); }
public async Task <IActionResult> Add([FromBody] ProposalModel proposal) { try { await service.Add(proposal); return(CreatedAtRoute("GetById", new { id = proposal.Id }, proposal)); } catch (Exception e) { return(BadRequest(e.Message)); } }
public async Task InvokeAsync(HttpContext httpContext, IProposalService proposalService) { try { if (httpContext.Request.Path.Value == "/Home/GetProposal") { var jsonRequestString = await FormatRequest(httpContext.Request); AddProposalLogRequest addLogRequest = JsonConvert.DeserializeObject <AddProposalLogRequest>(jsonRequestString); var addLogResult = await proposalService.Add(addLogRequest); var originalBodyStream = httpContext.Response.Body; using (var responseBody = new MemoryStream()) { httpContext.Response.Body = responseBody; await _next(httpContext); var jsonResponseString = await FormatResponse(httpContext.Response); var response = JsonConvert.DeserializeObject <GetProposalResponse>(jsonResponseString); var updateLogRequest = new UpdateProposalLogRequest { Id = addLogResult.Data.Id, Response = JsonConvert.SerializeObject(response) }; await proposalService.Update(updateLogRequest); await responseBody.CopyToAsync(originalBodyStream); } } else { await _next(httpContext); } } catch (Exception e) { //await HandleExceptionAsync(httpContext, e); } }
public async Task <IActionResult> Add([FromBody] ProposalModel proposal, int conferenceId) { var proposalAdded = await _proposalService.Add(proposal); return(CreatedAtRoute("GetById", new { proposalId = proposalAdded.Id }, proposalAdded)); }
public Proposal Add(Proposal entity) { return(proposalService.Add(entity)); }
public IActionResult Add([FromBody] ProposalModel proposal) { var addedProposal = _proposalService.Add(proposal); return(CreatedAtRoute("GetById", new { id = addedProposal.Id }, addedProposal)); }