public UpdateOpportunityViewResponse UpdateOpportunityName(UpdateOpportunityViewRequest request) { UpdateOpportunityViewResponse response = new UpdateOpportunityViewResponse(); Opportunity updatedOpportunity = opportunityRepository.FindBy(request.OpportunityID); updatedOpportunity.OpportunityName = request.OpportunityName; bool isOpportunityUnique = opportunityRepository.IsOpportunityUnique(updatedOpportunity); if (!isOpportunityUnique) { var message = "[|Opportunity with name|] \"" + updatedOpportunity.OpportunityName + "\" [|already exists.|]"; throw new UnsupportedOperationException(message); } opportunityRepository.UpdateOpportunityName(request.OpportunityID, request.OpportunityName, request.RequestedBy.Value); if (indexingService.Update <Opportunity>(updatedOpportunity) > 0) { Logger.Current.Verbose("Opportunity updated to elasticsearch successfully"); } OpportunityViewModel opportunityViewModel = Mapper.Map <Opportunity, OpportunityViewModel>(updatedOpportunity); response.opportunityViewModel = opportunityViewModel; return(response); }
public UpdateOpportunityViewResponse UpdateOpportunityImage(UpdateOpportunityViewRequest request) { UpdateOpportunityViewResponse response = new UpdateOpportunityViewResponse(); Opportunity updatedOpportunity = opportunityRepository.FindBy(request.OpportunityID); Image image = Mapper.Map <ImageViewModel, Image>(request.image); opportunityRepository.UpdateOpportunityImage(request.OpportunityID, image, request.RequestedBy.Value); if (indexingService.Update <Opportunity>(updatedOpportunity) > 0) { Logger.Current.Verbose("Opportunity updated to elasticsearch successfully"); } OpportunityViewModel opportunityViewModel = Mapper.Map <Opportunity, OpportunityViewModel>(updatedOpportunity); response.opportunityViewModel = opportunityViewModel; return(response); }