public static IBitmap GovernmentPortrait(IGovernment government, Advisor advisor, bool modern) { string filename; int governmentId; if (government is Monarchy) { governmentId = (modern ? 3 : 2); filename = $"GOVT1" + (modern ? "M" : "A"); } else if (government is Republic || government is Democracy) { governmentId = (modern ? 5 : 4); filename = $"GOVT2" + (modern ? "M" : "A"); } else if (government is Communism) { governmentId = 6; filename = "GOVT3A"; } else // Anarchy or Despotism { governmentId = (modern ? 1 : 0); filename = "GOVT0" + (modern ? "M" : "A"); } if (_governmentPortrait[governmentId, (int)advisor] == null) { _governmentPortrait[governmentId, (int)advisor] = Resources[filename][(40 * (int)advisor), 0, 40, 60]; } return(_governmentPortrait[governmentId, (int)advisor]); }
public Advisor SaveAsync(Advisor cls) { try { var headers = Request.Headers?.ToList(); if (headers == null || headers.Count <= 0) { return(null); } var guid = Request.Headers.GetValues("cusGuid").FirstOrDefault(); if (string.IsNullOrEmpty(guid)) { return(null); } var cusGuid = Guid.Parse(guid); if (!Assistence.CheckCustomer(cusGuid)) { return(null); } db.Advisor.AddOrUpdate(cls); db.SaveChanges(); Assistence.SaveLog(cusGuid, cls.Guid, EnTemp.Advisor); return(cls); } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); return(null); } }
//POST : /api/Advisor/Login public async Task <IActionResult> Login(Advisor advisor) { var user = await _userManager.FindByNameAsync(advisor.UserName); if (user != null && await _userManager.CheckPasswordAsync(user, advisor.Password)) { var tokenDescriptor = new SecurityTokenDescriptor { Subject = new ClaimsIdentity(new Claim[] { new Claim("UserID", user.Id.ToString()) }), Expires = DateTime.UtcNow.AddDays(1), SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_appSettings.JWT_Secret)), SecurityAlgorithms.HmacSha256Signature) }; var tokenHandler = new JwtSecurityTokenHandler(); var securityToken = tokenHandler.CreateToken(tokenDescriptor); var token = tokenHandler.WriteToken(securityToken); return(Ok(new { token })); } else { return(BadRequest(new { message = "Username or password is incorrect." })); } }
public void TestGetCustomersForAdvisor() { //arrange IRepository repository = MockRepository.GenerateStub<IRepository>(); ICustomerRepository customerRepository = MockRepository.GenerateStub<ICustomerRepository>(); IAccountServices accountServices = MockRepository.GenerateStub<IAccountServices>(); IDtoCreator<Customer, CustomerDto> custCreator = new CustomerDtoCreator(); Advisor advisor1 = new Advisor { Id = 1, FirstName = "Ad1"}; Advisor advisor2 = new Advisor {Id=2,FirstName = "Ad2"}; List<Customer> customers = new List<Customer>(); customers.Add(new Customer { Advisor = advisor1, Id = 1}); customers.Add(new Customer {Advisor = advisor2, Id = 2}); advisor1.Customers = customers; //repository.Expect(x=>x.GetAll<Customer>()).Return(customers); repository.Expect(x => x.Get<Advisor>(advisor1.Id)).Return(advisor1); //act CustomerServices services = new CustomerServices(customerRepository, repository,accountServices,custCreator); List<CustomerDto> recieved = (List<CustomerDto>)services.GetCustomersForAdvisor(advisor1.Id); //assert Assert.AreEqual(recieved[0].Id, 1); repository.VerifyAllExpectations(); }
public void Should_Intercept_Only_Attributed_Methods() { var aspectLog = new List<string>(); var serviceLog = new List<string>(); //Given var aspect = new SimpleAspect(); aspect.DoneSomething += (obj, ea) => aspectLog.Add(ea.Message); var simpleService = new SimpleService(); simpleService.DoneSomething += (obj, ea) => serviceLog.Add(ea.Message); var shouldNotBeCalledAspect = new Mock<IAspect>(MockBehavior.Strict); var advisor = new Advisor(JoinPointDefinition.AttributeBasedJoinPointDefinition, new List<IAspect>() {aspect, shouldNotBeCalledAspect.Object}); var myService = advisor.GetAdvicedProxy<ISimpleService>(simpleService); //Then var result = myService.DoSomething("hallo"); //When Assert.AreEqual(aspectLog[0], "aspectCalled"); Assert.AreEqual(aspectLog[1], "hallo"); Assert.AreEqual(aspectLog[2], "DoneSomething"); Assert.AreEqual(result, "executed"); Assert.AreEqual(serviceLog[0], "hallo"); shouldNotBeCalledAspect.VerifyAll(); }
public Permission GetUserRights(Account account, UserIdentity user) { if (user.Type == "Advisor") { Advisor advisor = _repository.Get <Advisor>(user.Id); if (advisor != null) { return(GetAdvisorRights(account, advisor)); } return(Permission.No); } else if (user.Type == "Customer") { Customer customer = _repository.Get <Customer>(user.Id); if (customer != null) { return(GetCustomerRights(account, customer)); } return(Permission.No); } else { throw new UserServicesException("Not expected type of user"); } }
public MainWindow() { StatusStack.ValueChanged += HandleStatusMsgChanged; Settings.Instance.SettingChange += HandleSettingChange; // Setup UI InitializeComponent(); m_log.LogEntryPattern = LogEntryPatternRegex; m_log.LogFilepath = Log.Filepath; // Collections OriginStarSystemsShortList = CollectionViewSource.GetDefaultView(new List <StarSystem>()); OriginStations = CollectionViewSource.GetDefaultView(new List <Station>()); DestStarSystemsShortList = CollectionViewSource.GetDefaultView(new List <StarSystem>()); DestStations = CollectionViewSource.GetDefaultView(new List <Station>()); Advisor = new Advisor(x => Dispatcher.BeginInvoke(x)); TradeRoutes = new ListCollectionView(Advisor.TradeRoutes); // Commands ShowSettings = Command.Create(this, ShowSettingsInternal); RebuildCache = Command.Create(this, RebuildCacheInternal); SetAsOrigin = Command.Create(this, SetAsOriginInternal); SetAsDestination = Command.Create(this, SetAsDestinationInternal); SwapOriDest = Command.Create(this, SwapOriDestInternal); Exit = Command.Create(this, Close); // UI Binding DataContext = this; // Start the advisor running Advisor.Run = true; }
public override void OnNavigatedTo(NavigationContext navigationContext) { Advisor = navigationContext.Parameters["Advisor"] as Advisor; CanRemoveAdvisor = false; if (Advisor != null && Advisor.Id > 0) { bool hasInvestors = AdvisorAccess.AdvisorHasInvestor(Advisor.Id); if (!hasInvestors) { CanRemoveAdvisor = true; } } if (Advisor != null) { Advisor.PropertyChanged -= Advisor_PropertyChanged; } RaisePropertyChanged("Advisor"); copyOfAdvisor = new Advisor(Advisor); TabTitle = Advisor.FullName; if (string.IsNullOrEmpty(TabTitle)) { TabTitle = "neuer Berater"; } var task = GetAllAdvisorAsync(); Advisor.PropertyChanged += Advisor_PropertyChanged; }
public void Should_Order_Aspects_From_Left_To_Right() { var aspectLog = new List<string>(); var serviceLog = new List<string>(); //Given var firstAspect = new FirstAspect(); firstAspect.DoneSomething += (obj, ea) => aspectLog.Add(ea.Message); var secondAspect = new SecondAspect(); secondAspect.DoneSomething += (obj, ea) => aspectLog.Add(ea.Message); var simpleService = new SimpleService(); simpleService.DoneSomething += (obj, ea) => serviceLog.Add(ea.Message); var shouldNotBeCalledAspect = new Mock<IAspect>(MockBehavior.Strict); var advisor = new Advisor(JoinPointDefinition.AttributeBasedJoinPointDefinition, new List<IAspect>() { shouldNotBeCalledAspect.Object, secondAspect, shouldNotBeCalledAspect.Object, firstAspect }); var myService = advisor.GetAdvicedProxy<ISimpleService>(simpleService); //Then var result = myService.DoMore("muchmore"); shouldNotBeCalledAspect.VerifyAll(); Assert.AreEqual(aspectLog.Count, 4); Assert.AreEqual("FirstAspectBefore", aspectLog[0]); Assert.AreEqual("SecondAspectBefore", aspectLog[1]); Assert.AreEqual("SecondAspectAfter", aspectLog[2]); Assert.AreEqual("FirstAspectAfter", aspectLog[3]); }
public int InsertAdvisor(Advisor model, int id) { try { DynamicParameters param = new DynamicParameters(); param.Add("@firstname", model.FirstName); param.Add("@lastname", model.LastName); param.Add("@address", model.Address); param.Add("@work_tel", model.WorkTel); param.Add("@cell", model.Cell); param.Add("@email", model.EmailAddress); param.Add("@rep_id", id); param.Add("@id", dbType: DbType.Int32, direction: ParameterDirection.Output); con.Open(); con.Execute("advisor_insert", param, commandType: CommandType.StoredProcedure); con.Close(); int advisor_id = param.Get <int>("@id"); return(advisor_id); } catch (Exception) { return(0); } }
public async void AddAdvisor(Advisor advisor, object userId) { var user = await Set.FindAsync(userId); user.Advisor = advisor; Update(user); }
public HttpResponseMessage CreateAdvisor(Advisor advisor) { var checkEmail = dbcontext.Advisors.Where(a_name => a_name.Email == advisor.Email).Any(); if (!checkEmail) { dbcontext.Advisors.Add(advisor); try { dbcontext.SaveChanges(); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex)); } HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, advisor); response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); return(response); } HttpResponseMessage res = Request.CreateResponse(HttpStatusCode.NotFound, "Not Found"); return(res); }
public void GetTaskForAdvisor_Found() { ITaskRepository taskRepository = new TaskRepository(NhibernateHelper.SessionFactory); Repository repository = new Repository(NhibernateHelper.SessionFactory); Advisor advisor = new Advisor { Id = 1, FirstName = "FirstName" }; Task task = new Task { Id = 1, Advisor = advisor }; Task task1 = new Task { Id = 2, Advisor = advisor }; using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction()) { repository.Save(advisor); repository.Save(task); repository.Save(task1); repository.Flush(); IList <Task> tasks = taskRepository.GetTasksForAdvisor(advisor.Id); Assert.AreEqual(2, tasks.Count); Assert.AreEqual(tasks[0].Advisor.FirstName, advisor.FirstName); } }
public async void AddAdvisor(Advisor advisor) { User user = await FindById(advisor.AdvisorId); user.Advisor = advisor; Update(user); }
// GET: Advisor /// <summary> /// Gets the profile for the given id /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Profiles() { AdvisorContext advisorContext = new AdvisorContext(); Advisor advisor = advisorContext.Advisors.Single(adv => adv.Id == 1); return(View(advisor)); }
public void SelectSourceCollection(IEnumerable <object> sourceCollection) { using (SelectionHandlingScope) { if (MultipleSelection) { foreach (var source in sourceCollection) { if (CurrentSelectionCollection.FindBySource(source, out _) == false) { if (Advisor.TryCreateSelection(source, false, out var selection) && selection.IsEmpty == false) { CurrentSelectionCollection.Select(selection); SetItemSelected(selection.Item, true); } } } SelectFirst(); } else { SelectSourceSafe(sourceCollection.FirstOrDefault()); } } }
public void Should_Memoize_Method_Result_On_Second_Call() { //Given var aspect = new TestAspect(); var received = new List<string>(); aspect.Executed += (sender, args) => received.Add(args.Message); var service = new Memoservice(); var advicedProxy = new Advisor( new MemoizeJointPointDefinition(VeryLongRunningAspectCalculation).GetMemoizedJointPointDefinition() , new List<IAspect>() { aspect }).GetAdvicedProxy<IMemoService>(service); //Then var stopwatch = new Stopwatch(); stopwatch.Start(); ResultObject retrieval = advicedProxy.DoAwfulLongRetrieval("test"); stopwatch.Stop(); Assert.IsTrue(stopwatch.ElapsedMilliseconds > 800); //When stopwatch.Reset(); stopwatch.Start(); advicedProxy.DoAwfulLongRetrieval("bamm"); stopwatch.Stop(); Assert.IsTrue(stopwatch.ElapsedMilliseconds < 100); }
public XmlElement ToXmlElement(XmlHelper helper) { var xmlElement = helper.CreateElement("AboutYou"); xmlElement.AppendChild(helper.CreateElement(nameof(IsInsured), UserIsInsured.ToString())); if (!UserIsInsured ?? false) { xmlElement.AppendChild(helper.CreateElement(nameof(InsuredFirstName), InsuredFirstName)); xmlElement.AppendChild(helper.CreateElement(nameof(InsuredLastName), InsuredLastName)); } xmlElement.AppendChild(helper.CreateElement(nameof(FirstName), FirstName)); xmlElement.AppendChild(helper.CreateElement(nameof(LastName), LastName)); xmlElement.AppendChild(helper.CreateElement(nameof(Email), Email)); xmlElement.AppendChild(helper.CreateElement(nameof(IsInsurancePolicyOwner), UserIsInsurancePolicyOwner.ToString())); if (!UserIsInsurancePolicyOwner) { xmlElement.AppendChild(helper.CreateElement(nameof(IsAgent), UserIsAgent.ToString())); if (UserIsAgent) { xmlElement.AppendChild(Advisor.ToXmlElement(helper)); } xmlElement.AppendChild(helper.CreateElement(nameof(SendInsuranceBenefitsTo), SendInsuranceBenefitsTo)); } xmlElement.AppendChild(helper.CreateElement(nameof(InsurancePolicies), InsurancePolicies.Where(x => x.MustBeValidated).Select(x => x.ToXmlElement(helper)).ToList())); return(xmlElement); }
public void TestGetCustomersForAdvisor() { //arrange IRepository repository = MockRepository.GenerateStub <IRepository>(); ICustomerRepository customerRepository = MockRepository.GenerateStub <ICustomerRepository>(); IAccountServices accountServices = MockRepository.GenerateStub <IAccountServices>(); IDtoCreator <Customer, CustomerDto> custCreator = new CustomerDtoCreator(); Advisor advisor1 = new Advisor { Id = 1, FirstName = "Ad1" }; Advisor advisor2 = new Advisor { Id = 2, FirstName = "Ad2" }; List <Customer> customers = new List <Customer>(); customers.Add(new Customer { Advisor = advisor1, Id = 1 }); customers.Add(new Customer { Advisor = advisor2, Id = 2 }); advisor1.Customers = customers; //repository.Expect(x=>x.GetAll<Customer>()).Return(customers); repository.Expect(x => x.Get <Advisor>(advisor1.Id)).Return(advisor1); //act CustomerServices services = new CustomerServices(customerRepository, repository, accountServices, custCreator); List <CustomerDto> recieved = (List <CustomerDto>)services.GetCustomersForAdvisor(advisor1.Id); //assert Assert.AreEqual(recieved[0].Id, 1); repository.VerifyAllExpectations(); }
public async Task <IActionResult> Edit(int id, [Bind("AdvisorID,Name,Surname,Email,BirthNumber,Age,Phone")] Advisor advisor) { if (id != advisor.AdvisorID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(advisor); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AdvisorExists(advisor.AdvisorID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(advisor)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,Address,PhoneNumber,HealthStatus")] Advisor advisor) { if (id != advisor.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(advisor); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AdvisorExists(advisor.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(advisor)); }
/// <summary> /// Constructor with one param: side /// side = 0: BLACK /// side = 1: RED /// </summary> /// <param name="side"></param> public Player(int side) { AdvisorPieces[0] = new Advisor(); AdvisorPieces[1] = new Advisor(); ElephantPieces[0] = new Elephant(); ElephantPieces[1] = new Elephant(); ChariotPieces[0] = new Chariot(); ChariotPieces[1] = new Chariot(); CannonPieces[0] = new Cannon(); CannonPieces[1] = new Cannon(); HorsePieces[0] = new Horse(); HorsePieces[1] = new Horse(); SoldierPieces[0] = new Soldier(); SoldierPieces[1] = new Soldier(); SoldierPieces[2] = new Soldier(); SoldierPieces[3] = new Soldier(); SoldierPieces[4] = new Soldier(); if (side == 0) // BLACK { //Side = 0; KingPiece.Init(0, "KING", 0, 1, true, 0, 4); AdvisorPieces[0].Init(0, "ADVISOR", 0, 1, true, 0, 3); AdvisorPieces[1].Init(0, "ADVISOR", 1, 1, true, 0, 5); ElephantPieces[0].Init(0, "ELEPHANT", 0, 1, true, 0, 2); ElephantPieces[1].Init(0, "ELEPHANT", 1, 1, true, 0, 6); HorsePieces[0].Init(0, "HORSE", 0, 1, true, 0, 1); HorsePieces[1].Init(0, "HORSE", 1, 1, true, 0, 7); ChariotPieces[0].Init(0, "CHARIOT", 0, 1, true, 0, 0); ChariotPieces[1].Init(0, "CHARIOT", 1, 1, true, 0, 8); CannonPieces[0].Init(0, "CANNON", 0, 1, true, 2, 1); CannonPieces[1].Init(0, "CANNON", 1, 1, true, 2, 7); SoldierPieces[0].Init(0, "SOLDIER", 0, 1, true, 3, 0); SoldierPieces[1].Init(0, "SOLDIER", 1, 1, true, 3, 2); SoldierPieces[2].Init(0, "SOLDIER", 2, 1, true, 3, 4); SoldierPieces[3].Init(0, "SOLDIER", 3, 1, true, 3, 6); SoldierPieces[4].Init(0, "SOLDIER", 4, 1, true, 3, 8); } else // RED { //Side = 1; KingPiece.Init(1, "KING", 0, 1, false, 9, 4); AdvisorPieces[0].Init(1, "ADVISOR", 0, 1, false, 9, 3); AdvisorPieces[1].Init(1, "ADVISOR", 1, 1, false, 9, 5); ElephantPieces[0].Init(1, "ELEPHANT", 0, 1, false, 9, 2); ElephantPieces[1].Init(1, "ELEPHANT", 1, 1, false, 9, 6); HorsePieces[0].Init(1, "HORSE", 0, 1, false, 9, 1); HorsePieces[1].Init(1, "HORSE", 1, 1, false, 9, 7); ChariotPieces[0].Init(1, "CHARIOT", 0, 1, false, 9, 0); ChariotPieces[1].Init(1, "CHARIOT", 1, 1, false, 9, 8); CannonPieces[0].Init(1, "CANNON", 0, 1, false, 7, 1); CannonPieces[1].Init(1, "CANNON", 1, 1, false, 7, 7); SoldierPieces[0].Init(1, "SOLDIER", 0, 1, false, 6, 0); SoldierPieces[1].Init(1, "SOLDIER", 1, 1, false, 6, 2); SoldierPieces[2].Init(1, "SOLDIER", 2, 1, false, 6, 4); SoldierPieces[3].Init(1, "SOLDIER", 3, 1, false, 6, 6); SoldierPieces[4].Init(1, "SOLDIER", 4, 1, false, 6, 8); } }
private static void CompareAdvisorProperties(Advisor expected, Advisor response, string expectedAutoExecuteStatus = null) { Assert.Equal(expected.Properties.AdvisorStatus, response.Properties.AdvisorStatus); Assert.Equal(expectedAutoExecuteStatus ?? expected.Properties.AutoExecuteStatus, response.Properties.AutoExecuteStatus); Assert.Equal(expected.Properties.AutoExecuteStatusInheritedFrom, response.Properties.AutoExecuteStatusInheritedFrom); Assert.Equal(expected.Properties.RecommendationsStatus, response.Properties.RecommendationsStatus); Assert.Equal(expected.Properties.LastChecked, response.Properties.LastChecked); }
public ActionResult DeleteConfirmed(int id) { Advisor advisor = db.Advisors.Find(id); db.Advisors.Remove(advisor); db.SaveChanges(); return(RedirectToAction("Index")); }
public int ValidateAdvisorSiteName(AdvisorCobrandInfo options) { if (string.IsNullOrEmpty(options.CobrandedSiteName)) { return(1); } return(Advisor.CobrandedSiteNameCheck(options)); }
public void Should_Only_Allow_Interfaces_to_proxy2() { //Given var advisor = new Advisor(new List<IAspect>()); //Then MSTestHelper.ShouldThrowException<ArgumentException>(() => advisor.GetAdvicedProxy(typeof(Target), new Target())); }
public void AddAdvisor(Advisor a) { if (planetAdvisors == null) { planetAdvisors = new List <Advisor>(); } planetAdvisors.Add(a); }
protected override void OnClosed(EventArgs e) { base.OnClosed(e); OriginStarSystemsShortList = null !; DestStarSystemsShortList = null !; OriginStations = null !; DestStations = null !; Advisor.Dispose(); }
public void FireAdvisor(AdvisorPanel panel) { Advisor a = panel.GetComponent <AdvisorPanel>().advisor; PlayerStatController.instance.advisorAssign.Remove(a); advisorPanels.Remove(panel); Destroy(panel.gameObject); advisorListHirePage.GetComponent <AdvisorListHire>().AddAdvisorFromBeingFired(panel); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { var validations = new List <ValidationResult>(); validations.AddRange(ValidatePolicies()); if (string.IsNullOrWhiteSpace(IsInsured)) { validations.Add(new ValidationResult(string.Empty, new[] { nameof(IsInsured) })); } else { if (string.IsNullOrWhiteSpace(FirstName) || FirstName.Length > 50) { validations.Add(new ValidationResult(string.Empty, new[] { nameof(FirstName) })); } if (string.IsNullOrWhiteSpace(LastName) || LastName.Length > 50) { validations.Add(new ValidationResult(string.Empty, new[] { nameof(LastName) })); } if (string.IsNullOrWhiteSpace(Email) || Email.Length > 50) { validations.Add(new ValidationResult(string.Empty, new[] { nameof(Email) })); } } if (!UserIsInsured ?? false) { if (string.IsNullOrWhiteSpace(InsuredFirstName) || InsuredFirstName.Length > 50) { validations.Add(new ValidationResult(string.Empty, new[] { nameof(InsuredFirstName) })); } if (string.IsNullOrWhiteSpace(InsuredLastName) || InsuredLastName.Length > 50) { validations.Add(new ValidationResult(string.Empty, new[] { nameof(InsuredLastName) })); } } if (string.IsNullOrWhiteSpace(IsInsurancePolicyOwner)) { validations.Add(new ValidationResult(string.Empty, new[] { nameof(IsInsurancePolicyOwner) })); } if (!UserIsInsurancePolicyOwner) { if (string.IsNullOrWhiteSpace(IsAgent)) { validations.Add(new ValidationResult(string.Empty, new[] { nameof(IsAgent) })); } if (UserIsAgent) { validations.AddRange(Advisor.Validate(nameof(Advisor), true)); if (string.IsNullOrWhiteSpace(SendInsuranceBenefitsTo)) { validations.Add(new ValidationResult(string.Empty, new[] { nameof(SendInsuranceBenefitsTo) })); } } } return(validations); }
public ActionResult Edit([Bind(Include = "Id,FirstName,LastName,Address,PhoneNumber,HealthStatus")] Advisor advisor) { if (ModelState.IsValid) { db.Entry(advisor).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(advisor)); }
public ActionResult Edit([Bind(Include = "AdvisorId")] Advisor advisor) { if (ModelState.IsValid) { db.Entry(advisor).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Home")); } return(View(advisor)); }
private void HandleLinkClicked(object sender, System.EventArgs e) { LinkLabel link = (LinkLabel)sender; Advisor advisor = (Advisor)link.Tag; if (advisor != _advisor) { LoadAdvisor(advisor); } }
public AdvisorDto GetAdvisorById(int id) { Advisor advisor = _repository.Get <Advisor>(id); if (advisor != null) { return(_advisorDtoCreator.Create(advisor)); } return(null); }
public Permission GetAdvisorRights(Account account, Advisor advisor) { foreach (Customer customer in account.RelatedCustomers.Keys) { if(advisor.Customers.Contains(customer)){ return advisor.Role.Permission; } } return 0; }
public ActionResult Edit([Bind(Include = "AdvisorID,FirstName,LastName,Email,Telephone")] Advisor advisor) { if (ModelState.IsValid) { db.Entry(advisor).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(advisor)); }
void Start () { advisor = GetComponent<Advisor>(); village = new SimpleVillage(100); foreach (var spot in villigerSpots) { spot.OnViligerHovered += advisor.ShowVilligerAdvice; spot.OnViligerSelected += OnViligerClicked; } NextYear(); }
public void Should_have_interface_type_in_AspectEnvironmen() { Func<IAspectEnvironment, IList<IAspect>, IList<IAspect>> checkConcreteType = (environMent, aspects) => { Assert.AreEqual(environMent.InterfaceType, typeof(ITarget)); return aspects; }; var proxiedClass = new Advisor(checkConcreteType, new List<IAspect>()).GetAdvicedProxy<ITarget>(new Target()); proxiedClass.DoneSomething("test"); }
public static Customer Create( string value_s, string value_s1, Advisor value_advisor, CustomerProfile value_customerProfile, string value_s2, string value_s3, DateTime value_dt, FamilySituation value_i, string value_s4, string value_s5, IList<UserTag> value_iList, IList<PaymentEvent> value_iList1_, IList<BusinessPartner> value_iList2_, IList<TagDepenses> value_iList3_, IList<CustomerImage> value_iList4_, IList<AuthToken> value_iList5_, int value_i1_, string value_s6, string value_s7, DateTime value_dt1, DateTime value_dt2, string value_s8, UserType value_i2_ ) { Customer customer = new Customer(); customer.Code = value_s; customer.PhoneNumber = value_s1; customer.Advisor = value_advisor; customer.CustomerProfile = value_customerProfile; customer.FirstName = value_s2; customer.LastName = value_s3; customer.BirthDate = value_dt; customer.Situation = value_i; customer.Password = value_s4; customer.PasswordSalt = value_s5; customer.Tags = value_iList; customer.PaymentEvents = value_iList1_; customer.Partners = value_iList2_; customer.TagDepenses = value_iList3_; customer.Images = value_iList4_; customer.Tokens = value_iList5_; ((UserIdentity)customer).Id = value_i1_; ((UserIdentity)customer).Identification = value_s6; ((UserIdentity)customer).Type = value_s7; ((UserIdentity)customer).ValidityEndDate = value_dt1; ((UserIdentity)customer).ValidityStartDate = value_dt2; ((UserIdentity)customer).Email = value_s8; ((UserIdentity)customer).UserType = value_i2_; return customer; }
public void Should_be_able_to_get_and_set_values_in_the_AspectEnvironment() { //Given var target = new Target(); Func<IAspectEnvironment, IList<IAspect>, IList<IAspect>> jointPointDefinition = JointPointDefinition; var proxiedTarget = new Advisor(jointPointDefinition, new List<IAspect>()).GetAdvicedProxy<ITarget>(target); //Then proxiedTarget.DoneSomething("test"); //When }
public void GetAdvisorByIdentity_Found_NotFound() { IAdvisorRepository advisorRepository = new AdvisorRepository(NhibernateHelper.SessionFactory); Repository repository = new Repository(NhibernateHelper.SessionFactory); Advisor advisor = new Advisor { Email = "*****@*****.**", FirstName = "Sim", LastName = "Lehericey", Identification="Ident"}; Advisor retrievedAdvisor; using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction()) { repository.Save(advisor); repository.Flush(); retrievedAdvisor = advisorRepository.GetAdvisorByIdentity(advisor.Identification); } Assert.IsNotNull(retrievedAdvisor); Assert.AreEqual(advisor.Email,retrievedAdvisor.Email); }
/** * add advisor to Advisors table * add playerToAdvisor to PlayerToAdvisor table */ public void AddAdvisor(Player player, Advisor[] advisors, int gameId) { foreach (Advisor a in advisors) { Advisor advisor = new Advisor(); advisor.First_Name = a.First_Name; advisor.Last_Name = a.Last_Name; db.Advisors.InsertOnSubmit(advisor); db.SubmitChanges(); PlayerToAdvisor p = new PlayerToAdvisor(); p.Player = player.Id; p.Advisor = advisor.Id; p.Game = gameId; db.PlayerToAdvisors.InsertOnSubmit(p); db.SubmitChanges(); } }
public void Should_Intercept_By_Aspects() { //Given var results = new List<string>(); var simpleAspect = new SimpleAspect(); var simpleService = new SimpleService(); simpleAspect.DoneSomething += (sender, args) => results.Add(args.Message); var advisor = new Advisor(new List<IAspect>() {simpleAspect}); var service = advisor.GetAdvicedProxy<ISimpleService>(simpleService); //Then var result = service.DoSomething("hllo"); //When Assert.AreEqual("executed", result); Assert.AreEqual("hllo", results[0]); Assert.AreEqual("donesomething", results[1]); }
public void onClickAdd(Advisor curadvisor) { dialoguecanvas = popup.GetComponent<PopupScript>().dialoguecanvas; dialoguepanel = popup.GetComponent<PopupScript>().dialoguepanel; Debug.Log ("CLICKY Add"); if (popup.GetComponent<PopupScript>().getTotalMoney() < curadvisor.price) { dialoguecanvas.SetActive(true); dialoguepanel.GetComponent<RectTransform>().anchoredPosition = new Vector2(0.0F, 0.0F); dialoguepanel.GetComponent<DisplayDialogScript>().title.text = "Too Little Money"; dialoguepanel.GetComponent<DisplayDialogScript>().message.text = "Yo, You Broke Son."; dialoguepanel.GetComponent<DisplayDialogScript>().falsebutton.gameObject.SetActive(false); dialoguepanel.GetComponent<DisplayDialogScript>().truebutton.GetComponentInChildren<Text>().text = "Continue"; dialoguepanel.GetComponent<DisplayDialogScript>().truebutton.onClick.AddListener(delegate { dialoguecanvas.SetActive(false); }); } else { if (advisorpanel.GetComponent<AdvisorScript>().myAdvisors.Count >= 5) { dialoguecanvas.SetActive(true); dialoguepanel.GetComponent<RectTransform>().anchoredPosition = new Vector2(0.0F, 0.0F); dialoguepanel.GetComponent<DisplayDialogScript>().title.text = "Too Many Advisors"; dialoguepanel.GetComponent<DisplayDialogScript>().message.text = "Maximum of Five Advisors. Go All 'The Apprentice' on Somebody."; dialoguepanel.GetComponent<DisplayDialogScript>().falsebutton.gameObject.SetActive(false); dialoguepanel.GetComponent<DisplayDialogScript>().truebutton.GetComponentInChildren<Text>().text = "Continue"; dialoguepanel.GetComponent<DisplayDialogScript>().truebutton.onClick.AddListener(delegate { dialoguecanvas.SetActive(false); }); } else { advisorpanel.GetComponent<AdvisorScript>().AddAdvisor(curadvisor); self.interactable = false; } } }
public void GetTaskForAdvisor_Found() { ITaskRepository taskRepository = new TaskRepository(NhibernateHelper.SessionFactory); Repository repository = new Repository(NhibernateHelper.SessionFactory); Advisor advisor = new Advisor { Id =1, FirstName="FirstName"}; Task task = new Task { Id = 1, Advisor = advisor }; Task task1 = new Task { Id = 2, Advisor = advisor }; using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction()) { repository.Save(advisor); repository.Save(task); repository.Save(task1); repository.Flush(); IList<Task> tasks = taskRepository.GetTasksForAdvisor(advisor.Id); Assert.AreEqual(2, tasks.Count); Assert.AreEqual(tasks[0].Advisor.FirstName, advisor.FirstName); } }
public void Should_put_value_in_KeyValueStore() { //Given var keyValueStore = new Mock<IKeyValueStore>(); keyValueStore .Setup(kv => kv.SetValue(It.Is<string>(st => st == "test"), It.IsAny<object>())) .AtMostOnce(); Func<IAspectEnvironment, IList<IAspect>, IList<IAspect>> kvSetValueFunc = (environment, aspect) => { environment.SetValue("test", new object()); return aspect; }; var proxiedTarget = new Advisor(kvSetValueFunc, new List<IAspect>()).GetAdvicedProxy<ITarget>(new Target(), keyValueStore.Object); //Then proxiedTarget.DoneSomething("bamm"); //When keyValueStore.VerifyAll(); }
void updateCampaigns(Advisor advisorremoved, Advisor advisoradded) { foreach (string region in regions.Keys) { } }
private void SubmitBtn_Click(object sender, EventArgs e) { if (ifValidPlayerName) { int b = 0; for (int i = 0; i < numOfAdvisors; i++) { if (!ifValidAdvisorsName[i]) { advisors = null; return; } else { Advisor a = new Advisor(); a.First_Name = advisorsTextBoxes.ElementAt(b++).Text; a.Last_Name = advisorsTextBoxes.ElementAt(b++).Text; advisors.Add(a); } } player1 = c.AddPlayer(playerFirstName.Text, playerLastName.Text); c.RegisterClient(player1); loadGameInfoPanel(); RegisterPanel.Visible = true; GameInfoPanel.Visible = true; playersComboBox.Enabled = false; } }
partial void UpdateAdvisor(Advisor instance);
partial void DeleteAdvisor(Advisor instance);
// public Advisor GenerateAdvisor(){ // List<string> nameList = new List<string> (); // } void BuyAdvisor(Advisor advisor){ advisor.hired = true; makeRows (); }
public override void DisplayInfluenceAdvisor( Advisor a, Player p, out List<object> returnData ) { // Displays info about the Advisor that is being influenced returnData = new List<object>(); GoodsChoiceOptions choice; switch( this.Mode ) { case graphicsMode.CLI: switch( a.AdvisorNameEnum ) { case Advisors.Jester: Console.WriteLine( "{0} influences the Jester, and receives 1 Victory Point.", p.Name ); break; case Advisors.Squire: Console.WriteLine( "{0} influences the Squire and receives 1 Gold.", p.Name ); break; case Advisors.Architect: Console.WriteLine( "{0} influences the Architect and receives 1 Wood.", p.Name ); break; case Advisors.Merchant: Console.WriteLine( "{0} influences the Merchant and receives 1 Wood OR 1 Gold.", p.Name ); choice = DisplayChooseAGood( p, GoodsChoiceOptions.Wood, GoodsChoiceOptions.Gold ); returnData.Add( choice ); break; case Advisors.Sergeant: Console.WriteLine( "{0} influences the Sergeant and recruits 1 Soldier.", p.Name ); break; case Advisors.Alchemist: Console.WriteLine( "{0} influences the Alchemist and can transmute 1 good.", p.Name ); GoodsChoiceOptions[] availableGoods = new GoodsChoiceOptions[3]; availableGoods[0] = p.Gold > 0 ? GoodsChoiceOptions.Gold : GoodsChoiceOptions.None; availableGoods[1] = p.Wood > 0 ? GoodsChoiceOptions.Wood : GoodsChoiceOptions.None; availableGoods[2] = p.Stone > 0 ? GoodsChoiceOptions.Stone : GoodsChoiceOptions.None; choice = DisplayChooseAGood( p, availableGoods ); returnData.Add( choice ); break; case Advisors.Astronomer: Console.WriteLine( "{0} influences the Astronomer and receives 1 good of choice and a \"+2\" token.", p.Name ); choice = DisplayChooseAGood( p, GoodsChoiceOptions.Gold, GoodsChoiceOptions.Wood, GoodsChoiceOptions.Stone ); returnData.Add( choice ); break; case Advisors.Treasurer: Console.WriteLine( "{0} influences the Treasurer and receives 2 Gold.", p.Name ); break; case Advisors.MasterHunter: Console.WriteLine( "{0} influences the Master Hunter and receives either 1 Wood and 1 Stone, or 1 Wood and 1 Gold.", p.Name ); choice = DisplayChooseAGood( p, GoodsChoiceOptions.WoodAndStone, GoodsChoiceOptions.GoldAndWood ); returnData.Add( choice ); break; case Advisors.General: Console.WriteLine( "{0} influences the General and recruits 2 soldiers and may spy on the enemy.", p.Name ); GameManager.Instance.UI.DisplayPeekAtEnemy( p ); break; case Advisors.Swordsmith: Console.WriteLine( "{0} influences the Swordsmith and receives either 1 Stone and 1 Wood, or 1 Stone and 1 Gold.", p.Name ); choice = DisplayChooseAGood( p, GoodsChoiceOptions.WoodAndStone, GoodsChoiceOptions.GoldAndStone ); returnData.Add( choice ); break; case Advisors.Duchess: Console.WriteLine( "{0} influences the Duchess and receives 2 goods of choice and a \"+2\" token.", p.Name ); choice = DisplayChooseAGood( p, GoodsChoiceOptions.Gold, GoodsChoiceOptions.Wood, GoodsChoiceOptions.Stone ); returnData.Add( choice ); choice = DisplayChooseAGood( p, GoodsChoiceOptions.Gold, GoodsChoiceOptions.Wood, GoodsChoiceOptions.Stone ); returnData.Add( choice ); break; case Advisors.Champion: Console.WriteLine( "{0} influences the Champion and receives 3 Stone.", p.Name ); break; case Advisors.Smuggler: Console.WriteLine( "{0} influences the Smuggler and pays 1 Victory Point to receive 3 goods of choice.", p.Name ); choice = DisplayChooseAGood( p, GoodsChoiceOptions.Gold, GoodsChoiceOptions.Wood, GoodsChoiceOptions.Stone ); returnData.Add( choice ); choice = DisplayChooseAGood( p, GoodsChoiceOptions.Gold, GoodsChoiceOptions.Wood, GoodsChoiceOptions.Stone ); returnData.Add( choice ); choice = DisplayChooseAGood( p, GoodsChoiceOptions.Gold, GoodsChoiceOptions.Wood, GoodsChoiceOptions.Stone ); returnData.Add( choice ); break; case Advisors.Inventor: Console.WriteLine( "{0} influences the Inventor and receives 1 Gold, 1 Wood, and 1 Stone.", p.Name ); break; case Advisors.Wizard: Console.WriteLine( "{0} influences the Wizard and receives 4 Gold.", p.Name ); break; case Advisors.Queen: Console.WriteLine( "{0} influences the Queen and receives 2 goods of choice, 3 Victory Points, and may spy on the enemy.", p.Name ); choice = DisplayChooseAGood( p, GoodsChoiceOptions.Gold, GoodsChoiceOptions.Wood, GoodsChoiceOptions.Stone ); returnData.Add( choice ); choice = DisplayChooseAGood( p, GoodsChoiceOptions.Gold, GoodsChoiceOptions.Wood, GoodsChoiceOptions.Stone ); returnData.Add( choice ); this.DisplayPeekAtEnemy( p ); break; case Advisors.King: Console.WriteLine( "{0} influences the King and receives 1 Gold, 1 Wood, and 1 Stone, and recruits 1 Soldier.", p.Name ); break; default: throw new Exception( "Something went wrong when running the DisplayInfluenceAdvisor method. Advisor={0}, Player={1}" ); } break; } }
public override DiceCollection DisplayChooseDice( Player p, Advisor a ) { switch( this.Mode ) { case graphicsMode.CLI: DiceCollection toReturn; SumComboFinder sc = new SumComboFinder(); List<List<KingsburgDie>> combos = sc.Find( a.Order, p.RemainingDice ); // Return the only combo if there is only one if( combos.Count == 1 ) { toReturn = new DiceCollection( combos[0] ); } else { Console.WriteLine( "\n{0}, pick which dice combo to use:", p.Name ); foreach( List<KingsburgDie> combo in combos ) { Console.Write( "{0}: ", combos.IndexOf( combo ) ); foreach( KingsburgDie d in combo ) { Console.Write( "{0}, ", d ); } Console.WriteLine(); } Console.WriteLine( "\"*\" indicates a white die." ); int chosenCombo = -1; do { string input = Console.ReadLine(); chosenCombo = int.Parse( input ); } while( chosenCombo == -1 || chosenCombo + 1 > combos.Count ); toReturn = new DiceCollection( combos[chosenCombo] ); } return toReturn; case graphicsMode.GUI: throw new NotImplementedException(); default: throw new Exception(); } }
public abstract DiceCollection DisplayChooseDice(Player p, Advisor a);
void FireAdvisor(Advisor advisor){ advisor.hired = false; makeRows (); }
public void DisplayInfluenceAdvisor(Advisor a, Player p) { List<object> dataWillBeDiscarded; DisplayInfluenceAdvisor(a, p, out dataWillBeDiscarded); }
public void removeFromAllCampaigns(Advisor adviser) { foreach (KeyValuePair<string, List<Campaign>> item in allcampaigns) { allcampaigns[item.Key] = allcampaigns[item.Key].Except(adviser.campaigns).ToList(); List<Campaign> overlapping = activecampaigns[item.Key].Except(adviser.campaigns).ToList(); foreach (Advisor adv in adviserspanel.GetComponent<AdvisorScript>().myAdvisors) { if (adv != adviser) { overlapping.AddRange((adv.campaigns.Except(overlapping)).ToList()); addToAllCampaigns(adv); } } activecampaigns[item.Key] = overlapping; } }
public void addToAllCampaigns(Advisor adviser) { foreach (KeyValuePair<string, List<Campaign>> item in allcampaigns){ allcampaigns[item.Key].AddRange((adviser.campaigns.Except(allcampaigns[item.Key])).ToList()); } }
public void AddAdvisor (Advisor curadvisor) { availableAdvisors.Remove (curadvisor); popupregion.GetComponent<PopupScript> ().IncreaseMoney (-curadvisor.price); GameObject[] corpbuts = GameObject.FindGameObjectsWithTag("AdvBut"); for (int j = 0; j < corpbuts.Length; j++) { if (corpbuts[j].GetComponent<AddAdvisorScript>().curadvisor == curadvisor) Destroy(corpbuts[j].transform.parent.gameObject); } myAdvisors.Add (curadvisor); popupregion.GetComponent<PopupScript>().addToAllCampaigns(curadvisor); makeRows (); }
public abstract void DisplayInfluenceAdvisor(Advisor a, Player p, out List<object> returnData);