private void SetNotifiesId(Negotiation negotiation, List <DdlDto> notifies) { if (negotiation.notify1Id == 0 || negotiation.notify2Id == 0) { if (notifies.SingleOrDefault(i => i.id == negotiation.consigneeId) != null) { //Notify1 same as consignee (consignee is required) if (negotiation.notify1Id == 0) { negotiation.notify1Id = negotiation.consigneeId; } //Notify2 sane as consignee (consignee is required) if (negotiation.notify2Id == 0) { negotiation.notify2Id = negotiation.consigneeId; } } } if (negotiation.notify2Id == 0) { negotiation.notify2Id = null; } if (negotiation.notify1Id == 0) { negotiation.notify1Id = null; } }
public bool CreateNegotiation(Negotiation negotiation) { _Context.Negotiations.Add(negotiation); _Context.SaveChanges(); return(true); }
public GeneralResponse NegotiationDelay(Guid NegotiationID, Guid EmployeeID, string NegotiationDate, string NegotiationTime, string RememberDate, string RememberTime) { GeneralResponse response = new GeneralResponse(); try { Negotiation negotiation = _negotiationRepository.FindBy(NegotiationID); negotiation.NegotiationDate = NegotiationDate; negotiation.NegotiationTime = NegotiationTime; negotiation.RememberTime = RememberTime; negotiation.ModifiedDate = PersianDateTime.Now; negotiation.ModifiedEmployee = _employeeRepository.FindBy(EmployeeID); _negotiationRepository.Save(negotiation); _uow.Commit(); } catch (Exception ex) { response.ErrorMessages.Add(ex.Message); if (ex.InnerException != null) { response.ErrorMessages.Add(ex.InnerException.Message); } } return(response); }
public IActionResult ArrowAceTwo(int id) { var str = db.Evaluation.Where(x => x.Id == id).ToList(); foreach (var val in str) // iterator the data from the list and insert them into the listSecond { string SalesStage = "Negotiation"; Negotiation ls = new Negotiation(); ls.Id = val.Id; ls.Name = val.Name; ls.Rep = val.Rep; ls.SalesStage = SalesStage; ls.Priority = val.Priority; ls.ExpectedCloseDate = val.ExpectedCloseDate; ls.ForeCastValue = val.ForeCastValue; ls.Probability = val.Probability; ls.LastContact = val.LastContact; ls.SignedContractValue = val.SignedContractValue; ls.Notes = val.Notes; db.Negotiation.Add(ls); } db.SaveChanges(); db.Evaluation.Remove(db.Evaluation.Find(id)); db.SaveChanges(); return(RedirectToAction("Index")); }
public bool IsValid(Negotiation negotiation) { var lastNegotiation = this.LastNegotiationByProduct(negotiation.ProductId); if (null != lastNegotiation && negotiation.Value <= lastNegotiation.Value) { _Validation.AddError("Value", $"Informa um lance com o valor maior que {lastNegotiation.ValueFormat}."); } else if (negotiation.Value <= negotiation.Product.Value) { _Validation.AddError("Value", $"Informe um valor maior que {negotiation.Product.ValueFormat}."); } if (negotiation.ProductId == 0) { _Validation.AddError("ProductId", "É necessário um produto para que haja uma negociação válida."); } if (negotiation.PersonId == 0) { _Validation.AddError("PersonId", "É necessário uma pessoa para que haja uma negociação válida."); } return(_Validation.IsValid); }
public GeneralResponse DeleteNegotiations(IEnumerable <DeleteRequest> requests) { GeneralResponse response = new GeneralResponse(); try { foreach (var deleteRequest in requests) { Negotiation negotiation = _negotiationRepository.FindBy(deleteRequest.ID); if (!negotiation.Closed) { _negotiationRepository.Remove(negotiation); } else { response.ErrorMessages.Add("مذاکره فروش بسته شده لذا امکان حذف ان وجود ندارد."); return(response); } } _uow.Commit(); } catch (Exception ex) { response.ErrorMessages.Add(ex.Message); if (ex.InnerException != null) { response.ErrorMessages.Add(ex.InnerException.Message); } } return(response); }
protected override void OnOfferReceivedEvent(object sender, Negotiation.Models.OfferEventArgs e) { if (PossibleEnemyVariants.Count > 1) { var utilites = PossibleEnemyVariants.Select(x => new { Variant = x, Utility = CalculateUtility(e.Offer.Offers, new SideConfig(OpponentSide, x)) }); double maxUtility = utilites.Max(x=>x.Utility); var removedEnemyVariants = utilites.Where(x => x.Utility < maxUtility).Select(x => x.Variant).ToList(); if (removedEnemyVariants.Count > 0) { foreach (var item in removedEnemyVariants) { PossibleEnemyVariants.Remove(item); BestCombinedUtilityOffers.Remove(item); BestFScoreUtilityOffers.Remove(item); } } } base.OnOfferReceivedEvent(sender, e); }
public GeneralResponse CloseNegotiation(Guid NegotiationID, Guid EmployeeID, Guid LeadResultTemplateID, string NegotiationResultDescription, int Status) { GeneralResponse response = new GeneralResponse(); try { Negotiation negotiation = _negotiationRepository.FindBy(NegotiationID); negotiation.Closed = true; negotiation.CloseDate = PersianDateTime.Now; negotiation.NegotiationStatus = NegotiationStatuses.Closed; negotiation.LeadResultTemplate = _leadResultTemplateRepository.FindBy(LeadResultTemplateID); negotiation.NeqotiationResultDescription = NegotiationResultDescription; _negotiationRepository.Save(negotiation); _uow.Commit(); } catch (Exception ex) { response.ErrorMessages.Add(ex.Message); if (ex.InnerException != null) { response.ErrorMessages.Add(ex.InnerException.Message); } } return(response); }
public void IsInvalidNegotiationWhenValueIsLessThanTheValueOfTheLastTrade() { var person = new Person(); person.Name = "Marcos Ferreira"; person.Email = "*****@*****.**"; person.DateOfBirth = new DateTime(1995, 10, 12); var product = new Product(); product.Name = "Macbook Pro 2020"; product.Value = 15000; var negotiation1 = new Negotiation(); negotiation1.PersonId = 1; negotiation1.Person = person; negotiation1.ProductId = 1; negotiation1.Product = product; negotiation1.Value = 16000; _NegotiationService.CreateNegotiation(negotiation1); var negotiation2 = new Negotiation(); negotiation2.PersonId = 1; negotiation2.Person = person; negotiation2.ProductId = 1; negotiation2.Product = product; negotiation2.Value = 15500; Assert.IsFalse(_NegotiationService.IsValid(negotiation2)); }
public async Task <Negotiation> UpdateNegotiationAsync(Negotiation negotiation) { _context.Negotiations.Update(negotiation); await _context.SaveChangesAsync(); return(negotiation); }
public async Task <bool> updateNegotiationplan(GetNegotiationplanDto getNegotiationplanDto) { try { Negotiationplan oNegotiationplan = await _Negotiationplans.SingleAsync(i => i.id == getNegotiationplanDto.id); if (!oNegotiationplan.isAccepted && getNegotiationplanDto.isAccepted) { if (await _Negotiationplans.AnyAsync(i => i.negotiationId == getNegotiationplanDto.negotiationId && i.isAccepted == true)) { return(true); } } if (getNegotiationplanDto.isAccepted) { Negotiation ONegotiation = await _Negotiation.SingleAsync(i => i.id == getNegotiationplanDto.negotiationId); ONegotiation.state = NegotiationStates.ConfirmedbyCustomer; } oNegotiationplan.planName = getNegotiationplanDto.planName; oNegotiationplan.isAccepted = getNegotiationplanDto.isAccepted; oNegotiationplan.modiferUserId = getNegotiationplanDto.userId; await _uow.SaveChangesAsync(); return(true); } catch { return(false); } }
public IActionResult Add(Negotiation Negotiation, Sales Sales) { db.Negotiation.Add(Negotiation); db.Sales.Add(Sales); db.SaveChanges(); return(RedirectToAction("Index")); }
public IActionResult Edit(int id, Negotiation Negotiation, Sales Sales) { db.Entry(Negotiation).State = Microsoft.EntityFrameworkCore.EntityState.Modified; db.Entry(Sales).State = Microsoft.EntityFrameworkCore.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
protected override void OnOfferReceivedEvent(object sender, Negotiation.Models.OfferEventArgs e) { OpponentOffer = e.Offer; if (CurrentOffer == null) { return; } CompareOffer(e.Offer); }
public void IsValidToApproveOrRejectNegotiationSecondStageBySupplierAsync(Negotiation negotiation) { if (negotiation == null) { throw new BusinessRuleException(Resources.CommunicationRequest.ErrorMessages.RequestNotFound); } if (negotiation.StatusId != (int)Enums.enNegotiationStatus.SentToSuppliers) { var RequestStatus = Resources.CommunicationRequest.Messages.ResourceManager.GetString(nameof(Enums.enNegotiationStatus.UnderUpdate)); throw new BusinessRuleException(Resources.CommunicationRequest.ErrorMessages.CanNotProceedStatusIs + RequestStatus); } }
public IActionResult Create([Bind("ProductId,PersonId,Value")] Negotiation negotiation) { _ValidationWrapper.SetModelState(this.ModelState); if (_NegotiationService.CreateNegotiation(negotiation)) { return(RedirectToAction("ShowAll", "Negotiation")); } _ValidationWrapper.MapTo(_NegotiationService.GetErrors()); return(View()); }
public override void Initialize(Negotiation.Models.NegotiationDomain domain, Negotiation.Models.SideConfig strategyConfig, string opponentSide, Negotiation.Models.INegotiationClient client) { base.Initialize(domain, strategyConfig, opponentSide, client); m_BestCombinedUtilityOffers = new Dictionary<string, OfferUtility>(BestCombinedUtilityOffers); m_BestFScoreUtilityOffers = new Dictionary<string, OfferUtility>(BestFScoreUtilityOffers); var opponentTypes = domain.OwnerVariantDict[opponentSide].Keys; m_typeProbabilites = opponentTypes.ToDictionary(k => k, x=>(1.0 / opponentTypes.Count)); var utilitySums = opponentTypes.ToDictionary(k=>k, k=>AllOptions.Values.Sum(x=>x.UtilityDataDict[k].OpponentUtility)); m_offerProbabilities = AllOptions.ToDictionary(kvp=>kvp.Key,kvp=>kvp.Value.UtilityDataDict.ToDictionary(kvp2=>kvp2.Key,kvp2=>kvp2.Value.OpponentUtility / utilitySums[kvp2.Key])); }
public bool CreateNegotiation(Negotiation negotiation) { negotiation.Product = _ProductRepository.GetProductById(negotiation.ProductId); if (!this.IsValid(negotiation)) { return(false); } negotiation.NegotiatedOn = DateTime.Now; _NegotiationRepository.CreateNegotiation(negotiation); return(true); }
public async Task <ActionResult> Get(Negotiation negotiation) { try { var auctions = await _repo.GetAllAuctionByNegotiationAsync(negotiation); var results = _mapper.Map <IEnumerable <AuctionDTO> >(auctions); return(Ok(results)); } catch (System.Exception) { return(this.StatusCode(StatusCodes.Status500InternalServerError, "Banco de dados falhou")); } }
protected override void OnOfferReceivedEvent(object sender, Negotiation.Models.OfferEventArgs e) { var opponentTypes = Domain.OwnerVariantDict[OpponentSide].Keys; var opponentOfferP = opponentTypes.Sum(x=>m_offerProbabilities[e.Offer][x] * m_typeProbabilites[x]); var newTypeProbabilites = opponentTypes.ToDictionary( x => x, x => m_offerProbabilities[e.Offer][x] * m_typeProbabilites[x] / opponentOfferP); GuessOpponentType(newTypeProbabilites.ArgMax(x => x.Value).Key); m_typeProbabilites = newTypeProbabilites; base.OnOfferReceivedEvent(sender, e); }
public void IsValidToEditOrFinishNegotiationSecondStageByCheckSecretaryAsync(Negotiation negotiation) { if (negotiation == null) { throw new BusinessRuleException(Resources.CommunicationRequest.ErrorMessages.RequestNotFound); } if (negotiation.StatusId != (int)Enums.enNegotiationStatus.CheckManagerReject && negotiation.StatusId != (int)Enums.enNegotiationStatus.UnitSpecialistReject) { var RequestStatus = Resources.CommunicationRequest.Messages.ResourceManager.GetString(nameof(Enums.enNegotiationStatus.CheckManagerReject)); throw new BusinessRuleException(Resources.CommunicationRequest.ErrorMessages.CanNotProceedStatusIs + RequestStatus); } if (negotiation.AgencyCommunicationRequest.Tender.AgencyCode != _httpContextAccessor.HttpContext.User.UserAgency()) { throw new UnHandledAccessException(); } }
public void IsValidToReopenNegotiation(Negotiation negotiation) { if (negotiation == null) { throw new BusinessRuleException(Resources.CommunicationRequest.ErrorMessages.RequestNotFound); } if (negotiation.StatusId != (int)Enums.enNegotiationStatus.CheckManagerReject && negotiation.StatusId != (int)Enums.enNegotiationStatus.UnitSpecialistReject) { var RequestStatus = Resources.CommunicationRequest.Messages.ResourceManager.GetString(nameof(Enums.enNegotiationStatus.UnderUpdate)); throw new BusinessRuleException(Resources.CommunicationRequest.ErrorMessages.CanNotProceedStatusIs + RequestStatus); } if (negotiation.StatusId == (int)Enums.enNegotiationStatus.New || negotiation.StatusId == (int)Enums.enNegotiationStatus.UnderUpdate) { throw new BusinessRuleException(Resources.CommunicationRequest.ErrorMessages.CanNotProceedStatusIs + " تحت التحديث"); } }
public GeneralResponse CreateNegotiationForCustomers(IEnumerable <Guid> CustomerIDs, Guid ReferedEmployeeID, Guid LeadTitleTemplateID, string NegotiationDesciption, string NegotiationDate, string NegotiationTime, string RememberDate, string RememberTime, bool?SendSms, Guid EmployeeID) { GeneralResponse response = new GeneralResponse(); try { foreach (var item in CustomerIDs) { Negotiation negotiation = new Negotiation(); negotiation.ID = Guid.NewGuid(); negotiation.CreateDate = PersianDateTime.Now; negotiation.CreateEmployee = _employeeRepository.FindBy(EmployeeID); negotiation.RowVersion = 1; negotiation.Customer = _customerRepository.FindBy(item); negotiation.LeadTitleTemplate = _leadTitleTemplateRepository.FindBy(LeadTitleTemplateID); negotiation.NegotiationDate = NegotiationDate; negotiation.NegotiationTime = NegotiationTime; negotiation.RememberTime = RememberTime; negotiation.ReferedEmployee = _employeeRepository.FindBy(ReferedEmployeeID); negotiation.NegotiationDesciption = NegotiationDesciption; negotiation.SendSms = SendSms != null && (bool)SendSms; _negotiationRepository.Add(negotiation); _uow.Commit(); } } catch (Exception ex) { response.ErrorMessages.Add(ex.Message); if (ex.InnerException != null) { response.ErrorMessages.Add(ex.InnerException.Message); } } return(response); }
protected override void OnNegotiate(Negotiation negotiation) { if (negotiation.History.Count == 0 && RelationTo(negotiation.Opponent) < Relation.Alliance) { negotiation.SetOurNextStatement(new SuggestTrade(new ITradeItem[] { new ChangeRelation(RelationTo(negotiation.Opponent) + 1) }, null)); // suggest better treaty } if (negotiation.History.Count > 0 && negotiation.History[0].OpponentResponse is SuggestTrade) { SuggestTrade trade = negotiation.History[0].OpponentResponse as SuggestTrade; if ((trade.Offers.Length == 1 && trade.Wants.Length == 0 && trade.Offers[0] is ChangeRelation && ((ChangeRelation)trade.Offers[0]).NewRelation > RelationTo(negotiation.Opponent) || (trade.Offers.Length == 0 && trade.Wants.Length == 1 && trade.Wants[0] is ChangeRelation && ((ChangeRelation)trade.Wants[0]).NewRelation > RelationTo(negotiation.Opponent)))) { negotiation.SetOurNextStatement(new AcceptTrade()); // accept better treaty } } }
public async Task <Auction[]> GetAllAuctionByNegotiationAsync(Negotiation negotiation) { var auctions = await _context.Auctions .Where(a => a.Negotiation == negotiation) .ToArrayAsync(); foreach (Auction auction in auctions) { auction.AuctionItems = await _context.AuctionItems .Where(ai => ai.AuctionId == auction.Id) .ToListAsync(); foreach (AuctionItem auctionItem in auction.AuctionItems) { auctionItem.Item = await _context.Items .FirstOrDefaultAsync(i => i.Id == auctionItem.ItemId); } } return(auctions); }
public async Task <GetNegotiationDto> getNegotiation(BaseDto baseDto) { Negotiation oNegotiation = await _Negotiations.AsNoTracking().SingleOrDefaultAsync(i => i.id == baseDto.id); GetNegotiationDto oNegotiationDto = Mapper.Map <Negotiation, GetNegotiationDto>(oNegotiation); oNegotiationDto.state = (Utilities.Enum.NegotiationStates)oNegotiation.state; if (oNegotiation.contractorId == oNegotiation.shipperId) { oNegotiationDto.contractor = CustomerTypes.Shipper; } else if (oNegotiation.contractorId == oNegotiation.consigneeId) { oNegotiationDto.contractor = CustomerTypes.Consignee; } else if (oNegotiation.contractorId == oNegotiation.notify1Id) { oNegotiationDto.contractor = CustomerTypes.Notify1; } else if (oNegotiation.contractorId == oNegotiation.notify2Id) { oNegotiationDto.contractor = CustomerTypes.Notify2; } if (oNegotiation.notify1Id == oNegotiation.consigneeId) { oNegotiationDto.notify1Id = 0; } if (oNegotiation.notify2Id == oNegotiation.consigneeId) { oNegotiationDto.notify2Id = 0; } return(await fillDdl(oNegotiationDto)); }
public GeneralResponse AddNegotiation(AddNegotiationRequest request, Guid EmployeeID) { GeneralResponse response = new GeneralResponse(); try { Negotiation negotiation = new Negotiation(); negotiation.ID = Guid.NewGuid(); negotiation.CreateDate = PersianDateTime.Now; negotiation.CreateEmployee = _employeeRepository.FindBy(EmployeeID); negotiation.RowVersion = 1; negotiation.Customer = _customerRepository.FindBy(request.CustomerID); negotiation.LeadTitleTemplate = _leadTitleTemplateRepository.FindBy(request.LeadTitleTemplateID); negotiation.NegotiationDate = request.NegotiationDate; negotiation.NegotiationTime = request.NegotiationTime; negotiation.RememberTime = request.RememberTime; negotiation.SendSms = request.SendSms != null && (bool)request.SendSms; negotiation.ReferedEmployee = request.ReferedEmployeeID == null ? _employeeRepository.FindBy(EmployeeID) : _employeeRepository.FindBy((Guid)request.ReferedEmployeeID); negotiation.NegotiationDesciption = request.NegotiationDesciption; _negotiationRepository.Add(negotiation); _uow.Commit(); } catch (Exception ex) { response.ErrorMessages.Add(ex.Message); if (ex.InnerException != null) { response.ErrorMessages.Add(ex.InnerException.Message); } } return(response); }
public Task SendToGroup(string groupName, string message, int projId, int userId, string userNickName) { Project proj = _projRepo.GetProjById(projId); Negotiation nego; int buyerId = Int32.Parse(groupName.Substring(groupName.LastIndexOf('-') + 1)); if (_negoRepo.BuyerHasNegoWithProj(buyerId, projId) || userId != buyerId) { nego = _negoRepo.GetNegoByBuyerProjId(buyerId, projId); } else { nego = new Negotiation { MyProj = proj, BuyerId = userId }; if (proj.TradingStatus == ProjStatus.No_Contact_Yet && !_projRepo.HasAnyNegosToLookat(projId)) { proj.TradingStatus = ProjStatus.Under_Negotiation; } _negoRepo.AddNego(nego); }; NegoEntry negoEntry = new NegoEntry { MyNego = nego, UserId = userId, UserNickName = userNickName, Timestamp = DateTime.Now, Text = message, }; _negoRepo.AddNegoEntry(negoEntry); return(Clients.Group(groupName).InvokeAsync("Send", userNickName + ": " + message)); }
public void IsInvalidNegotiationWhenTradingValueLessThanProductValue() { var person = new Person(); person.Name = "Marcos Ferreira"; person.Email = "*****@*****.**"; person.DateOfBirth = new DateTime(1995, 10, 12); var product = new Product(); product.Name = "Macbook Pro 2020"; product.Value = 15000; var negotiation = new Negotiation(); negotiation.PersonId = 1; negotiation.Person = person; negotiation.ProductId = 1; negotiation.Product = product; negotiation.Value = 14000; Assert.IsFalse(_NegotiationService.IsValid(negotiation)); }
public GeneralResponse ChangeNegotiationReferedEmployee(IEnumerable <Guid> NegotiationIDs, Guid EmployeeID, Guid ReferedEmployeeID, string NegotiationDate, string NegotiationTime, string RememberDate, string RememberTime) { GeneralResponse response = new GeneralResponse(); try { foreach (var item in NegotiationIDs) { Negotiation negotiation = _negotiationRepository.FindBy(item); if (negotiation.Closed) { response.ErrorMessages.Add("مذاکره بسته شده را نمیتوان ارجاع داد."); return(response); } negotiation.ReferedEmployee = _employeeRepository.FindBy(ReferedEmployeeID); negotiation.ModifiedDate = PersianDateTime.Now; negotiation.ModifiedEmployee = _employeeRepository.FindBy(EmployeeID); negotiation.NegotiationStatus = NegotiationStatuses.Refered; negotiation.NegotiationDate = NegotiationDate; negotiation.NegotiationTime = NegotiationTime; negotiation.RememberTime = RememberTime; _negotiationRepository.Save(negotiation); } _uow.Commit(); } catch (Exception ex) { response.ErrorMessages.Add(ex.Message); if (ex.InnerException != null) { response.ErrorMessages.Add(ex.InnerException.Message); } } return(response); }
public GeneralResponse EditNegotiation(EditNegotiationRequest request, Guid EmployeeID) { GeneralResponse response = new GeneralResponse(); try { Negotiation negotiation = _negotiationRepository.FindBy(request.ID); if (!negotiation.Closed) { negotiation.Customer = _customerRepository.FindBy(request.CustomerID); negotiation.LeadTitleTemplate = _leadTitleTemplateRepository.FindBy(request.LeadTitleTemplateID); negotiation.NegotiationDate = request.NegotiationDate; negotiation.NegotiationTime = request.NegotiationTime; negotiation.NegotiationDesciption = request.NegotiationDesciption; negotiation.RememberTime = request.RememberTime; negotiation.ReferedEmployee = _employeeRepository.FindBy(request.ReferedEmployeeID == null ? (Guid)EmployeeID : (Guid)request.ReferedEmployeeID); negotiation.SendSms = request.SendSms != null && (bool)request.SendSms; _negotiationRepository.Save(negotiation); _uow.Commit(); } } catch (Exception ex) { response.ErrorMessages.Add(ex.Message); if (ex.InnerException != null) { response.ErrorMessages.Add(ex.InnerException.Message); } } return(response); }
public override void Initialize(Negotiation.Models.NegotiationDomain domain, Negotiation.Models.SideConfig strategyConfig, string opponentSide, Negotiation.Models.INegotiationClient client) { base.Initialize(domain, strategyConfig, opponentSide, client); PossibleEnemyVariants = new HashSet<String>(domain.OwnerVariantDict[opponentSide].Keys); }
public void IsValidToApproveOrRejectNegotiationSecondStageByUnitSecretaryAsync(Negotiation negotiation) { if (negotiation == null) { throw new BusinessRuleException(Resources.CommunicationRequest.ErrorMessages.RequestNotFound); } if (negotiation.StatusId != (int)Enums.enNegotiationStatus.UnitSpecialestPendingApproved) { var RequestStatus = Resources.CommunicationRequest.Messages.ResourceManager.GetString(nameof(Enums.enNegotiationStatus.UnitSpecialestPendingApproved)); throw new BusinessRuleException(Resources.CommunicationRequest.ErrorMessages.CanNotProceedStatusIs + RequestStatus); } }
public async Task <bool> insertNegotiation(GetNegotiationDto dto) { try { Negotiation oNegotiation = Mapper.Map <GetNegotiationDto, Negotiation>(dto); #region Create RefrenceNo string part1_Year = DateTime.Now.Year.ToString().Substring(2); string part2_Type = "O"; string part3_counter = "00001"; string currentMax = await _Negotiations.Where(i => i.referenceNo.Substring(0, 2) == part1_Year && i.referenceNo.Substring(2, 1) == part2_Type).Select(i => i.referenceNo.Substring(3)).MaxAsync(); if (currentMax != null) { part3_counter = BuildKey.BuildReferenceKey(currentMax); } oNegotiation.referenceNo = part1_Year + part2_Type + part3_counter; #endregion oNegotiation.isInboundProcess = false; #region Cost plust set total net price if (oNegotiation.isCostplus) { oNegotiation.costplusPercent = dto.costplusPercent; } else { oNegotiation.totalNetPrice = dto.totalNetPrice; } #endregion oNegotiation.contractorId = SetContractorId(dto.contractor, dto.shipperId, dto.consigneeId, dto.notify1Id, dto.notify2Id); SetNotifiesId(oNegotiation, dto.notifys1); #region Cost plus and set total net price if (dto.notify1Id == 0 || dto.notify2Id == 0) { if (dto.notifys1.SingleOrDefault(i => i.id == dto.consigneeId) != null) { //Notify1 same as consignee (consignee is required) if (dto.notify1Id == 0) { oNegotiation.notify1Id = oNegotiation.consigneeId; } //Notify2 sane as consignee (consignee is required) if (dto.notify2Id == 0) { oNegotiation.notify2Id = oNegotiation.consigneeId; } } } #endregion _Negotiations.Add(oNegotiation); await _uow.SaveChangesAsync(); return(true); } catch (Exception ex) { return(false); } }
private void btnCalculate_Click(object sender, EventArgs e) { //declaring variables string workshop, city; decimal workshopCost, lodgingCost, totalCost; int days; //declare constants for workshop prices & lodging base pricing const decimal HandlingStress = 1000, TimeManagement = 800, SupervisionSkills = 1500, Negotiation = 1300, HowToInterview = 500, AustinLodging = 150, ChicagoLodging = 225, DallasLodging = 175, OrlandoLodging = 300, PhoenixLodging = 175, RaleighLodging = 150; if (lstWorkshop.SelectedIndex != -1) { workshop = lstWorkshop.SelectedItem.ToString(); //setup price for each workshop switch (workshop) { case "Handling Stress": txtRegistrationCost.Text = HandlingStress.ToString("c"); workshopCost = 1000m; days = 3; break; case "Time Management": txtRegistrationCost.Text = TimeManagement.ToString("c"); workshopCost = 800m; days = 3; break; case "Supervision Skills": txtRegistrationCost.Text = SupervisionSkills.ToString("c"); workshopCost = 1500m; days = 3; break; case "Negotiation": txtRegistrationCost.Text = Negotiation.ToString("c"); workshopCost = 1300; days = 5; break; case "How to Interview": txtRegistrationCost.Text = HowToInterview.ToString("c"); workshopCost = 500m; days = 1; break; } } else { //No Workshop Selected :( MessageBox.Show("Select a Workshop!"); } if (lstLocation.SelectedIndex != -1) { city = lstLocation.SelectedItem.ToString(); //setup price for each city switch (city) { case "Austin": txtLodgingCost.Text = AustinLodging.ToString("c"); lodgingCost = 150; break; case "Chicago": txtLodgingCost.Text = ChicagoLodging.ToString("c"); lodgingCost = 225; break; case "Dallas": txtLodgingCost.Text = DallasLodging.ToString("c"); lodgingCost = 175; break; case "Orlando": txtLodgingCost.Text = OrlandoLodging.ToString("c"); lodgingCost = 300; break; case "Phoenix": txtLodgingCost.Text = PhoenixLodging.ToString("c"); lodgingCost = 175; break; case "Raleigh": txtLodgingCost.Text = RaleighLodging.ToString("c"); lodgingCost = 150; break; } } else { //No City Selected :( MessageBox.Show("Select a City!"); } { //calculate totals if (decimal.TryParse(txtRegistrationCost.Text, out workshopCost)) { if (decimal.TryParse(txtLodgingCost.Text, out lodgingCost)) { totalCost = lodgingCost + workshopCost; txtTotalCost.Text = totalCost.ToString("c"); } else { } } else { } } }