public ConsumerResponseScheme UpdateResponseAsRejected(ConsumerResponseScheme scheme) { var response = FindById(scheme.Id); if (response != null) { // update the response state to rejected (tracking receipts are updated) response.SetReceiptState(ResponseReceiptStates.Rejected, this.AccountSession); // update to the DB response = Update(response); // log successful update this.Logger.Info(string.Format("successfully set response state to rejected for Id {0} via user {1}", scheme.Id, this.AccountSession.MemberId)); // create and return the new provider response scheme var consumerPortfolio = this.Mongo.GetConsumerPortfolio(response.ConsumerPortfolioId); var providerPortfolio = this.Mongo.GetProviderPortfolio(response.ProviderPortfolioId); // notify the switch board this.Switchboard.ResponseUpdatedAsUserRejected(response, providerPortfolio, consumerPortfolio); // return the updated scheme return(GetConsumerResponseScheme(response.Id)); } else { // log non-existent consumer group this.Logger.Warn(string.Format("could not set response to rejected for Id {0} because it does not exist via user {1}", scheme.Id, this.AccountSession.MemberId)); } return(scheme); }
public HttpResponseMessage UpdateResponseAsRejected(ConsumerResponseScheme response) { var schemeValidation = response.Validate(this.AccountSession, ValidationMode.Reject); if (schemeValidation.IsValid) { try { // handle the submission to the rejected state var results = this.Uow.Responses.UpdateResponseAsRejected(response); // return the updated results return(CreateSuccessResponse(new { success = true, results = results }, HttpStatusCode.OK)); } catch (Exception ex) { // log exception Logger.Error(string.Format("Exception detected attempting to set state to rejected for Id {0} via user {1}", response.Id, this.AccountSession.MemberId), ex); return(CreateErrorResponse(ex)); } } // invalid parameters, generate response return(CreateInvalidResponse(schemeValidation)); }
public ConsumerResponseScheme GetConsumerResponseScheme(string id) { // get the responses for this consumer var response = this.Mongo.GetResponseById(id); // get the consumer portfolio var consumerPortfolio = this.Mongo.GetConsumerPortfolio(response.ConsumerPortfolioId); // get the provider portfolio var providerPortfolio = this.Mongo.GetProviderPortfolio(response.ProviderPortfolioId); // build the scheme var responseScheme = new ConsumerResponseScheme(response, consumerPortfolio, providerPortfolio); return(responseScheme); }
public void ResponseUpdated(Response response, ConsumerPortfolio consumerPortfolio, ProviderPortfolio providerPortfolio) { // find the identities for this consumer portfolio ID var identities = this.Identities.Where(item => item.PortfolioId == consumerPortfolio.Id); if (!identities.Any()) { return; } // build a consumer response scheme to send out var responseScheme = new ConsumerResponseScheme(response, consumerPortfolio, providerPortfolio); // send this out to all client identities foreach (var identity in identities) { // send out the updated resoponse scheme this.HubContext.Clients.Client(identity.ConnectionId).ResponseUpdated(responseScheme); // trace the transmission of this response this.Logger.Trace(string.Format("updated response for Id {0} automatically transmitted to consumer portfolio {1} for user Id {2} with connection Id {3}", response.Id, identity.PortfolioId, identity.UserId, identity.ConnectionId)); } }