/// <summary> /// Tries searching for a deal type by its name in the Proposal Manager API. If found, assigns it to the provided opportunity. /// </summary> /// <param name="opportunity">The opportunity to modify.</param> /// <param name="proposalManagerClient">A initialized Proposal Manager client.</param> /// <param name="dealTypeName">The name of the deal type to assign.</param> /// <returns></returns> private async Task <OpportunityViewModel> TryAssignDealType(OpportunityViewModel opportunity, HttpClient proposalManagerClient, string dealTypeName) { var processResult = await proposalManagerClient.GetAsync("/api/Template"); if (!processResult.IsSuccessStatusCode) { _logger.LogError("DYNAMICS INTEGRATION ENGINE: Proposal Manager did not return a success status code on Template request."); return(null); } var processList = await processResult.Content.ReadAsAsync <TemplateListViewModel>(); var dealType = processList.ItemsList.FirstOrDefault(x => x.TemplateName == dealTypeName); if (dealType == null) { _logger.LogError($"DYNAMICS INTEGRATION ENGINE: Required deal type ({dealTypeName}) doesn't exist in Proposal Manager."); return(null); } //Deal Type found. Assign it to Opportunity. Doing same process as UI... opportunity.Template = dealType; opportunity.Template.ProcessList.First(p => p.ProcessStep == "Start Process").Status = ActionStatus.Completed; opportunity.OpportunityState = OpportunityStateModel.InProgress; return(opportunity); }
public async Task <IActionResult> LinkSharePointLocationsAsync([FromBody] OpportunityViewModel opportunity) { try { if (opportunity is null || !ModelState.IsValid) { return(BadRequest()); } if (!string.IsNullOrWhiteSpace(opportunity.Reference)) { var locations = from pl in opportunity.Template.ProcessList where pl.Channel.ToLower() != "base" && pl.Channel.ToLower() != "none" select pl.Channel; _logger.LogInformation($"Locations detected for opportunity {opportunity.DisplayName}: {string.Join(", ", locations)}"); await dynamicsLinkService.CreateLocationsForOpportunityAsync(opportunity.Reference, opportunity.DisplayName, locations); } return(Ok()); } catch (Exception ex) { var message = $"LinkSharePointLocationsAsync error: {ex.Message}"; _logger.LogError(message); _logger.LogError(ex.StackTrace); return(BadRequest(message)); } }
public async Task <StatusCodes> UpdateItemAsync(OpportunityViewModel opportunityViewModel, string requestId = "") { _logger.LogInformation($"RequestId: {requestId} - UpdateItemAsync called."); Guard.Against.Null(opportunityViewModel, nameof(opportunityViewModel), requestId); Guard.Against.NullOrEmpty(opportunityViewModel.Id, nameof(opportunityViewModel.Id), requestId); var currentOppModel = await GetItemByIdAsync(opportunityViewModel.Id, requestId); var currentOpp = await _opportunityHelpers.ToOpportunityAsync(currentOppModel, Opportunity.Empty, requestId); if (opportunityViewModel.Id == currentOpp.Id) { try { var opportunity = await _opportunityHelpers.ToOpportunityAsync(opportunityViewModel, currentOpp, requestId); var result = await _opportunityRepository.UpdateItemAsync(opportunity, requestId); Guard.Against.NotStatus200OK(result, "UpdateItemAsync", requestId); return(result); } catch (Exception ex) { _logger.LogError($"RequestId: {requestId} - UpdateItemAsync Service Exception: {ex}"); throw new ResponseException($"RequestId: {requestId} - UpdateItemAsync Service Exception: {ex}"); } } else { _logger.LogError($"RequestId: {requestId} - UpdateItemAsync Service error: mistmatch"); throw new ResponseException($"RequestId: {requestId} - UpdateItemAsync Service Exception: mistmatch"); } }
public void PostOpportunity_validOpportunity_Succeed() { OpportunitiesController controller = new OpportunitiesController(mockContactService.Object, mockOpportunitiesService.Object); this.SetupControllerTests(controller, "http://localhost/STCRMService/api/opportunity", HttpMethod.Post); var mockResponse = mockRepository.Create <InsertOpportunityResponse>(); OpportunityViewModel newOpportunity = new OpportunityViewModel() { OpportunityID = SAMPLE_OPPORTUNITY_ID, CreatedBy = 1, CreatedOn = DateTime.Now }; mockResponse.Setup(c => c.opportunityViewModel).Returns(newOpportunity); mockOpportunitiesService.Setup(c => c.InsertOpportunity(It.IsAny <InsertOpportunityRequest>())).Returns(mockResponse.Object); var httpResponseMessage = controller.InsertOpportunity(newOpportunity); var postResponse = httpResponseMessage.Content.ReadAsAsync <InsertOpportunityResponse>().ContinueWith( t => { return(t.Result); }).Result; var contactResponse = postResponse.opportunityViewModel; mockRepository.VerifyAll(); Assert.IsTrue(postResponse.opportunityViewModel.OpportunityID > 0, "Id is not greater than zero after insert."); Assert.AreEqual(httpResponseMessage.StatusCode, HttpStatusCode.OK); Assert.AreEqual(postResponse.Exception, null); }
public async Task <OpportunityViewModel> GetItemByRefAsync(string reference, string requestId = "") { _logger.LogInformation($"RequestId: {requestId} - GetItemByRefAsync called."); Guard.Against.NullOrEmpty(reference, nameof(reference), requestId); try { var thisOpportunity = new Opportunity(); thisOpportunity = await _opportunityRepository.GetItemByRefAsync(reference, requestId); var opportunityViewModel = new OpportunityViewModel(); reference = reference.Replace("'", ""); if (thisOpportunity.Reference != reference) { _logger.LogWarning($"RequestId: {requestId} - GetItemByRefAsync no items found"); throw new NoItemsFound($"RequestId: {requestId} - Method name: GetItemByRefAsync - No Items Found"); } else { opportunityViewModel = await _opportunityHelpers.ToOpportunityViewModelAsync(thisOpportunity, requestId); } // TODO: foreach service to filter out data you don't have access return(opportunityViewModel); } catch (Exception ex) { _logger.LogError($"RequestId: {requestId} - GetItemByRefAsync Service Exception: {ex}"); throw new ResponseException($"RequestId: {requestId} - GetItemByRefAsync Service Exception: {ex}"); } }
public ActionResult Create([Bind(Exclude = "Id")] Opportunity opportunity) { string userName = this.User.Identity.Name; int accountId = Int32.Parse(Request.Form["Opportunity.AccountId"]);/*we prefix, as the account is inside the Opportunity editor*/ //we get the user responsible for the opportunity User responsibleUser = _userService.GetUser(userName); //we get the account from the db Account account = _accountService.GetAccount(accountId); opportunity.ResponsibleUser = responsibleUser; opportunity.Account = account; if (!_opportunityService.CreateOpportunity(opportunity)) { var accounts = _accountService.ListAccounts(); var viewModel = new OpportunityViewModel(opportunity) { Accounts = new SelectList(accounts, "Id", "Name") }; return(View(viewModel)); } return(RedirectToAction("Index")); }
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); }
// GET: Opportunities/Create public ActionResult Create() { OpportunityViewModel opportunityViewModel = new OpportunityViewModel(); opportunityViewModel.Id = _opportunity.Count; return(View(opportunityViewModel)); }
public Task <Opportunity> MapToEntityAsync(Opportunity entity, OpportunityViewModel viewModel, string requestId = "") { //try //{ // if (entity.Content.CustomerFeedback == null) entity.Content.CustomerFeedback = new CustomerFeedback(); // if (viewModel.CustomerFeedback != null) // { // var item = viewModel.CustomerFeedback; // var customerFeedback = CustomerFeedback.Empty; // var existingAnalysis = entity.Content.CustomerFeedback; // if (existingAnalysis != null) customerFeedback = existingAnalysis; // customerFeedback.Id = item.Id ?? String.Empty; // customerFeedback.CustomerFeedbackStatus = ActionStatus.FromValue(item.CustomerFeedbackStatus.Value); // customerFeedback.CustomerFeedbackChannel = item.CustomerFeedbackChannel ?? String.Empty; // entity.Content.CustomerFeedback = customerFeedback; // } return(Task.FromResult(entity)); //} //catch (Exception ex) //{ // throw new ResponseException($"RequestId: {requestId} - CustomerFeedbackProcessService MapToEntity oppId: {entity.Id} - failed to map opportunity: {ex}"); //} }
public async Task <Opportunity> MapToEntityAsync(Opportunity entity, OpportunityViewModel viewModel, string requestId = "") { try { if (entity.Content.CustomerFeedback == null) { entity.Content.CustomerFeedback = CustomerFeedback.Empty; } if (viewModel.CustomerFeedback != null) { var updatedFeedbacks = new CustomerFeedback(); updatedFeedbacks.Id = viewModel.CustomerFeedback.Id ?? String.Empty; updatedFeedbacks.CustomerFeedbackChannel = viewModel.CustomerFeedback.CustomerFeedbackChannel ?? String.Empty; updatedFeedbacks.CustomerFeedbackList = viewModel.CustomerFeedback.CustomerFeedbackList.Select(feedback => new CustomerFeedbackItem { Id = feedback.Id ?? String.Empty, FeedbackContactMeans = feedback.FeedbackContactMeans ?? ContactMeans.Unkwown, FeedbackDate = feedback.FeedbackDate, FeedbackSummary = feedback.FeedbackSummary ?? String.Empty, FeedbackDetails = feedback.FeedbackDetails ?? String.Empty }).ToList(); entity.Content.CustomerFeedback = updatedFeedbacks; } return(entity); } catch (Exception ex) { throw new ResponseException($"RequestId: {requestId} - CheckListProcessService MapToEntity oppId: {entity.Id} - failed to map opportunity: {ex}"); } }
// GET: /Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tbl_Opportunity opportunity = db.tbl_Opportunity.Find(id); if (opportunity == null) { return(HttpNotFound()); } var Results = from b in db.tbl_Category select new { b.Category_Id, b.CategoryName, Checked = ((from ab in db.OPPOR_HAS_CATEGORY where (ab.Oppor_Id == id) & (ab.Category_Id == b.Category_Id) select ab).Count() > 0) }; var MyViewModel = new OpportunityViewModel(); MyViewModel.Oppor_Id = id.Value; MyViewModel.Oppor_Name = opportunity.Oppor_Name; MyViewModel.Oppor_Description = opportunity.Oppor_Description; MyViewModel.Oppor_Dateofevent = opportunity.Oppor_Dateofevent; MyViewModel.ImageData = opportunity.ImageData; MyViewModel.ImageMimeType = opportunity.ImageMimeType; MyViewModel.Oppor_Streetaddress = opportunity.Oppor_Streetaddress; MyViewModel.Oppor_Streetaddress2 = opportunity.Oppor_Streetaddress2; MyViewModel.Oppor_City = opportunity.Oppor_City; MyViewModel.Oppor_State = opportunity.Oppor_State; MyViewModel.Oppor_Zip = opportunity.Oppor_Zip; MyViewModel.Oppor_County = opportunity.Oppor_County; MyViewModel.Oppor_Eldersource = opportunity.Oppor_Eldersource; MyViewModel.Oppor_Eldersourceinstitute = opportunity.Oppor_Eldersourceinstitute; MyViewModel.Oppor_RequiresBackgroundCheck = opportunity.Oppor_RequiresBackgroundCheck; MyViewModel.Oppor_IsFeatured = opportunity.Oppor_IsFeatured; MyViewModel.Oppor_CreatedOn = opportunity.Oppor_CreatedOn; MyViewModel.UserId = opportunity.UserId; MyViewModel.Role = opportunity.Role; var MyCheckBoxList = new List <CheckBoxViewModel>(); foreach (var item in Results) { MyCheckBoxList.Add(new CheckBoxViewModel { Id = item.Category_Id, Name = item.CategoryName, Checked = item.Checked }); } MyViewModel.Categories = MyCheckBoxList; return(View(MyViewModel)); }
public async Task <OpportunityViewModel> MapToModelAsync(Opportunity entity, OpportunityViewModel viewModel, string requestId = "") { //Granular bug fix : Start //Temp fix for checklist process update //Overriding granular access while getting exsiting opportunity model from sharepoint var overrideAccess = _authorizationService.GetGranularAccessOverride(); //Granular bug fix : End //Granular Access : Start var permissionsNeeded = new List <ApplicationCore.Entities.Permission>(); List <string> list = new List <string>(); var access = true; //going for super access list.AddRange(new List <string> { Access.Opportunities_Read_All.ToString(), Access.Opportunities_ReadWrite_All.ToString() }); permissionsNeeded = (await _permissionRepository.GetAllAsync(requestId)).ToList().Where(x => list.Any(x.Name.Contains)).ToList(); if (!(StatusCodes.Status200OK == await _authorizationService.CheckAccessAsync(permissionsNeeded, requestId))) { //going for opportunity access access = await _authorizationService.CheckAccessInOpportunityAsync(entity, PermissionNeededTo.Read, requestId); if (!access) { access = await _authorizationService.CheckAccessInOpportunityAsync(entity, PermissionNeededTo.ReadPartial, requestId); if (access) { //going for partial accesss list.Clear(); list.AddRange(new List <string> { "customerdecision_read", "customerdecision_readwrite" }); permissionsNeeded = (await _permissionRepository.GetAllAsync(requestId)).ToList().Where(x => list.Any(x.Name.Contains)).ToList(); access = StatusCodes.Status200OK == await _authorizationService.CheckAccessAsync(permissionsNeeded, requestId) ? true : false; } else { access = false; } } } if (access || overrideAccess) { viewModel.CustomerDecision = new CustomerDecisionModel { Id = entity.Content.CustomerDecision.Id, Approved = entity.Content.CustomerDecision.Approved, ApprovedDate = entity.Content.CustomerDecision.ApprovedDate, LoanDisbursed = entity.Content.CustomerDecision.LoanDisbursed }; } //Granular Access : End return(viewModel); }
public ActionResult Edit(OpportunityViewModel opportunity, HttpPostedFileBase image = null) { if (ModelState.IsValid) { if (image != null) { opportunity.ImageMimeType = image.ContentType; opportunity.ImageData = new byte[image.ContentLength]; image.InputStream.Read(opportunity.ImageData, 0, image.ContentLength); } var MyOpportunity = db.tbl_Opportunity.Find(opportunity.Oppor_Id); MyOpportunity.Oppor_Name = opportunity.Oppor_Name; MyOpportunity.Oppor_Description = opportunity.Oppor_Description; MyOpportunity.Oppor_Dateofevent = opportunity.Oppor_Dateofevent; MyOpportunity.ImageData = opportunity.ImageData; MyOpportunity.ImageMimeType = opportunity.ImageMimeType; MyOpportunity.Oppor_Streetaddress = opportunity.Oppor_Streetaddress; MyOpportunity.Oppor_Streetaddress2 = opportunity.Oppor_Streetaddress2; MyOpportunity.Oppor_City = opportunity.Oppor_City; MyOpportunity.Oppor_State = opportunity.Oppor_State; MyOpportunity.Oppor_Zip = opportunity.Oppor_Zip; MyOpportunity.Oppor_County = opportunity.Oppor_County; MyOpportunity.Oppor_Eldersource = opportunity.Oppor_Eldersource; MyOpportunity.Oppor_Eldersourceinstitute = opportunity.Oppor_Eldersourceinstitute; MyOpportunity.Oppor_RequiresBackgroundCheck = opportunity.Oppor_RequiresBackgroundCheck; MyOpportunity.Oppor_IsFeatured = opportunity.Oppor_IsFeatured; MyOpportunity.Oppor_CreatedOn = opportunity.Oppor_CreatedOn; MyOpportunity.UserId = opportunity.UserId; MyOpportunity.Role = opportunity.Role; foreach (var item in db.OPPOR_HAS_CATEGORY) { if (item.Oppor_Id == opportunity.Oppor_Id) { db.Entry(item).State = System.Data.Entity.EntityState.Deleted; } } foreach (var item in opportunity.Categories) { if (item.Checked) { db.OPPOR_HAS_CATEGORY.Add(new OPPOR_HAS_CATEGORY() { Oppor_Id = opportunity.Oppor_Id, Category_Id = item.Id }); } } db.SaveChanges(); TempData["message"] = string.Format("{0} has been saved", opportunity.Oppor_Name); return(RedirectToAction("Index")); } return(View(opportunity)); }
public void EmptyOpportunityIsInvalid() { var opportunity = new OpportunityViewModel(); var context = new ValidationContext(opportunity); var isModelStateValid = Validator.TryValidateObject(opportunity, context, new List <ValidationResult>(), true); Assert.IsFalse(isModelStateValid); }
// // GET: /Opportunity/Create public ActionResult Create() { var accounts = _accountService.ListAccounts(); var viewModel = new OpportunityViewModel { Accounts = new SelectList(accounts, "Id", "Name") }; return(View(viewModel)); }
private OpportunityViewModel CreateViewModel(string id) { var opportunity = new OpportunityViewModel { Id = id, ExpectedInput = new OpportunityInputModel(), }; return(opportunity); }
public async Task <OpportunityViewModel> MapToModelAsync(Opportunity entity, OpportunityViewModel viewModel, string requestId = "") { //try //{ // var item = entity.Content.CustomerFeedback; // var overrideAccess = _authorizationService.GetGranularAccessOverride(); // var permissionsNeeded = new List<Permission>(); // var list = new List<string>(); // var access = true; // list.AddRange(new List<string> { Access.Opportunities_Read_All.ToString(), Access.Opportunities_ReadWrite_All.ToString() }); // permissionsNeeded = (await _permissionRepository.GetAllAsync(requestId)).ToList().Where(x => list.Any(x.Name.Contains)).ToList(); // if (!(StatusCodes.Status200OK == await _authorizationService.CheckAccessAsync(permissionsNeeded, requestId))) // { // access = await _authorizationService.CheckAccessInOpportunityAsync(entity, PermissionNeededTo.Read, requestId); // if (!access) // { // //going for partial accesss // access = await _authorizationService.CheckAccessInOpportunityAsync(entity, PermissionNeededTo.ReadPartial, requestId); // if (access) // { // var channel = item.CustomerFeedbackChannel.Replace(" ", ""); // var partialList = new List<string>(); // partialList.AddRange(new List<string> { $"CustomerFeedbackProcessService_read", $"CustomerFeedbackProcessService_readwrite" }); // permissionsNeeded = (await _permissionRepository.GetAllAsync(requestId)).ToList().Where(x => partialList.Any(x.Name.ToLower().Contains)).ToList(); // access = StatusCodes.Status200OK == await _authorizationService.CheckAccessAsync(permissionsNeeded, requestId) ? true : false; // } // else // access = false; // } // } // if (access || overrideAccess) // { // var customerFeedbackModel = new CustomerFeedbackModel // { // Id = item.Id, // CustomerFeedbackStatus = item.CustomerFeedbackStatus, // CustomerFeedbackChannel = item.CustomerFeedbackChannel // }; // viewModel.CustomerFeedback = customerFeedbackModel; // } return(viewModel); //} //catch (Exception ex) //{ // throw new ResponseException($"RequestId: {requestId} - CustomerFeedbackProcessService MapToModel oppId: {entity.Id} - failed to map opportunity: {ex}"); //} }
public async Task <IActionResult> Index() { var opportunities = await _opportunityService.GetIncompleteOpportunitesAsync(); var model = new OpportunityViewModel() { Opportunities = opportunities }; return(View(model)); }
public static OpportunityViewModel GetMock() { OpportunityViewModel mockOpportunity = new OpportunityViewModel(); mockOpportunity.OpportunityID = 1; mockOpportunity.OpportunityName = "OpportunityName"; mockOpportunity.CreatedOn = DateTime.Now; mockOpportunity.CreatedBy = 1; return(mockOpportunity); }
public async Task <ViewResult> Edit(Guid Id) { var opportunities = await _opportunityService.GetIncompleteOpportunitesAsync(); var model = new OpportunityViewModel() { Opportunities = opportunities }; return(View(model.Opportunities.FirstOrDefault(v => v.Id == Id))); }
public ActionResult Edit(OpportunityViewModel opportunity) { if (ModelState.IsValid) { var entity = Mapper.Map <Opportunity>(opportunity); opportunityService.Update(entity); return(RedirectToAction("Index")); } ViewBag.CampaignSourceId = new SelectList(campaignSourceService.GetAll(), "Id", "Name"); ViewBag.CompanyId = new SelectList(companyService.GetAll(), "Id", "Owner"); ViewBag.ContactId = new SelectList(contactService.GetAll(), "Id", "Owner"); ViewBag.LeadSourceId = new SelectList(leadSourceService.GetAll(), "Id", "Name"); return(View(opportunity)); }
// GET: Opportunities/Details/5 public ActionResult Details(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } OpportunityViewModel opportunity = Mapper.Map <OpportunityViewModel>(opportunityService.Get(id.Value)); if (opportunity == null) { return(HttpNotFound()); } return(View(opportunity)); }
public async Task <IActionResult> IndexAsync(int id) { List <Opportunity> opportunities = await MemoryCacheImpl.GetOpportunitiesAcceptingApplications(_memoryCache, _context); OpportunityViewModel opportunityView = opportunities .Where(x => x.Id == id) .Select(OpportunityViewModel.FromOpportunity) .SingleOrDefault(); if (opportunityView == null) { return(View(new OpportunityViewModel())); } return(View(opportunityView)); }
public ActionResult Create(OpportunityViewModel opportunity) { if (ModelState.IsValid) { var entity = Mapper.Map <Opportunity>(opportunity); //view modelden alınanı entity e dönüştürüyor. opportunityService.Insert(entity); return(RedirectToAction("Index")); } ViewBag.CampaignSourceId = new SelectList(campaignSourceService.GetAll(), "Id", "Name"); ViewBag.CompanyId = new SelectList(companyService.GetAll(), "Id", "Owner"); ViewBag.ContactId = new SelectList(contactService.GetAll(), "Id", "Owner"); ViewBag.LeadSourceId = new SelectList(leadSourceService.GetAll(), "Id", "Name"); return(View(opportunity)); }
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); }
// GET: Admin/tbl_Opportunity/Create public ActionResult Create() { //tbl_Opportunity opportunity = db.tbl_Opportunity.Find(id); tbl_Opportunity opportunity = new tbl_Opportunity(); var Results = from b in db.tbl_Category select new { b.Category_Id, b.CategoryName, }; var MyViewModel = new OpportunityViewModel(); MyViewModel.Oppor_Id = opportunity.Oppor_Id; MyViewModel.Oppor_Name = opportunity.Oppor_Name; MyViewModel.Oppor_Description = opportunity.Oppor_Description; MyViewModel.Oppor_Dateofevent = opportunity.Oppor_Dateofevent; MyViewModel.ImageData = opportunity.ImageData; MyViewModel.ImageMimeType = opportunity.ImageMimeType; MyViewModel.Oppor_Streetaddress = opportunity.Oppor_Streetaddress; MyViewModel.Oppor_Streetaddress2 = opportunity.Oppor_Streetaddress2; MyViewModel.Oppor_City = opportunity.Oppor_City; MyViewModel.Oppor_State = opportunity.Oppor_State; MyViewModel.Oppor_Zip = opportunity.Oppor_Zip; MyViewModel.Oppor_County = opportunity.Oppor_County; MyViewModel.Oppor_Eldersource = opportunity.Oppor_Eldersource; MyViewModel.Oppor_Eldersourceinstitute = opportunity.Oppor_Eldersourceinstitute; MyViewModel.Oppor_RequiresBackgroundCheck = opportunity.Oppor_RequiresBackgroundCheck; MyViewModel.Oppor_IsFeatured = opportunity.Oppor_IsFeatured; MyViewModel.Oppor_CreatedOn = opportunity.Oppor_CreatedOn; MyViewModel.UserId = opportunity.UserId; MyViewModel.Role = opportunity.Role; var MyCheckBoxList = new List <CheckBoxViewModel>(); foreach (var item in Results) { MyCheckBoxList.Add(new CheckBoxViewModel { Id = item.Category_Id, Name = item.CategoryName, Checked = false }); } MyViewModel.Categories = MyCheckBoxList; return(View(MyViewModel)); }
// GET: Opportunities/Edit/5 public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } OpportunityViewModel opportunity = Mapper.Map <OpportunityViewModel>(opportunityService.Get(id.Value)); if (opportunity == null) { return(HttpNotFound()); } ViewBag.CampaignSourceId = new SelectList(campaignSourceService.GetAll(), "Id", "Name"); ViewBag.CompanyId = new SelectList(companyService.GetAll(), "Id", "Owner"); ViewBag.ContactId = new SelectList(contactService.GetAll(), "Id", "Owner"); ViewBag.LeadSourceId = new SelectList(leadSourceService.GetAll(), "Id", "Name"); return(View(opportunity)); }
public GetOpportunityResponse getOpportunity(GetOpportunityRequest request) { GetOpportunityResponse response = new GetOpportunityResponse(); hasAccess(request.OpportunityID, request.RequestedBy, request.AccountId, request.RoleId); Opportunity opportunity = opportunityRepository.FindBy(request.OpportunityID); if (opportunity == null) { response.Exception = GetOpportunitiesNotFoundException(); } else { SearchContactsRequest contactsRequest = new SearchContactsRequest(); contactsRequest.ContactIDs = opportunity.Contacts.ToArray(); contactsRequest.AccountId = request.AccountId; contactsRequest.RoleId = request.RoleId; contactsRequest.RequestedBy = request.RequestedBy; contactsRequest.Limit = opportunity.Contacts.Count(); contactsRequest.PageNumber = 1; SearchContactsResponse <ContactEntry> contactsResponse = contactService.GetAllContacts <ContactEntry>(contactsRequest); IEnumerable <int> people = opportunity.Contacts; var contacts = contactsResponse.Contacts.Where(c => people.Contains(c.Id)); IEnumerable <Tag> tags = tagRepository.FindByOpportunity(request.OpportunityID); OpportunityViewModel opportunityViewModel = Mapper.Map <Opportunity, OpportunityViewModel>(opportunity); opportunityViewModel.Contacts = contacts; opportunityViewModel.ContactCount = opportunity.Contacts.Count(); response.OpportunityViewModel = opportunityViewModel; opportunityViewModel.TagsList = tags; if (opportunity.ImageID != null) { Image image = opportunityRepository.GetOpportunityProfileImage(opportunity.ImageID.Value); opportunityViewModel.Image = Mapper.Map <Image, ImageViewModel>(image); opportunityViewModel.Image.ImageContent = urlService.GetUrl(opportunityViewModel.AccountID, ImageCategory.OpportunityProfile, opportunityViewModel.Image.StorageName); } } return(response); }
public async Task <Opportunity> MapToEntityAsync(Opportunity entity, OpportunityViewModel viewModel, string requestId = "") { try { if (entity.Content.ProposalDocument == null) { entity.Content.ProposalDocument = ProposalDocument.Empty; } if (viewModel.ProposalDocument != null) { entity.Content.ProposalDocument = await ProposalDocumentToEntityAsync(viewModel, entity.Content.ProposalDocument, requestId); } return(entity); } catch (Exception ex) { throw new ResponseException($"RequestId: {requestId} - ProposalStatusProcessService MapToEntity oppId: {entity.Id} - failed to map opportunity: {ex}"); } }
// // GET: /Opportunity/Edit/5 public ActionResult Edit(int id) { //getting the opportunity to edit Opportunity opportunity = _opportunityService.GetOpportunity(id); if (opportunity == null) { Response.StatusCode = (int)HttpStatusCode.NotFound; return(View("NotFound")); } var accounts = _accountService.ListAccounts(); var viewModel = new OpportunityViewModel(opportunity) { Accounts = new SelectList(accounts, "Id", "Name") }; return(View(viewModel)); }