public async Task Add(CityHall cityHall) { if (!ExecuteValidation(new CityHallValidation(), cityHall)) { return; } bool userExists = await _userService.FirebaseUserExistsByEmail(cityHall.Email); if (userExists) { Notify("Endereço de e-mail já cadastrado no sistema."); return; } await _repository.Add(cityHall); CityHall newCityHall = await _repository.GetById(cityHall.Id); if (newCityHall != null) { UserRecordArgs args = new UserRecordArgs() { DisplayName = newCityHall.Name, Email = newCityHall.Email, Password = newCityHall.CNPJ }; UserRecord fbUser = await _firebaseAuth.CreateUserAsync(args); if (fbUser != null) { User newUser = new User() { FirebaseUserId = fbUser.Uid, Email = fbUser.Email, CreationDate = DateTime.Now, FirstName = fbUser.DisplayName, CityHallId = newCityHall.Id }; await _userService.Add(newUser); // await _relationHandler.UpdateRelationAsync(newUser.Id, newCityHall.Id, true); var claims = new Dictionary <string, object>() { { "app_user_id", newUser.Id }, { "user", true }, { "city_hall", true } }; await _roleService.UpdateUserRole("user", newUser.Id, true); await _roleService.UpdateUserRole("city_hall", newUser.Id, true); await _roleService.UpdateUserClaims(newUser.Id, claims); } } }
public AñadirUsuario(IGestDepService service, CityHall city, String s) { InitializeComponent(); this.service = service; this.city = city; dni.Text = s; }
public InscribirEnActividad(IGestDepService service, CityHall c, Gym g) { InitializeComponent(); this.service = service; this.ciudad = c; this.gimnasio = g; LoadData(); }
/// <summary> /// Inserts into the database a new CityHall with a default name /// </summary> /// <returns>The new CittyHall</returns> public CityHall InsertCityHall() { cityHallCount++; CityHall cityHall = new CityHall(CITY_HALL_NAME); dal.Insert(cityHall); dal.Commit(); return(cityHall); }
public async Task <ActionResult> UpdateCityHall(Guid id, CityHallUpdateDto data) { CityHall updateCityHall = await _repository.GetById(id); _mapper.Map(data, updateCityHall); await _service.Update(updateCityHall); return(Ok(updateCityHall)); }
/// <summary> /// Inserts gyms in the DB associated to cityHall /// </summary> /// <param name="numberNewGyms">Number of gyms to insert </param> /// <param name="cityHall">The citiHall which containg the gym. It must be previously inserted in the dal</param> /// <returns>A collection with the gyms inserted</returns> public ICollection <Gym> InsertGyms(int numberNewGyms, CityHall cityHall) { ICollection <Gym> newGyms = new List <Gym>(); for (int i = 0; i < numberNewGyms; i++) { newGyms.Add(InsertGym(cityHall)); } return(newGyms); }
/// <summary> /// Inserts a new gym in the DB associated to cityHall /// </summary> /// <param name="cityHall">The citiHall which containg the gym. It must be previously inserted in the dal</param> /// <returns>Gym inserted</returns> public Gym InsertGym(CityHall cityHall) { gymCount++; Gym gym = new Gym(GYM_CLOSING_HOUR, GYM_DISCOUNT_LOCAL, GYM_DISCOUNT_RETIRED, GYM_FREE_USER_PRICE, GYM_NAME + gymCount, GYM_OPENING_HOUR, GYM_ZIP_CODE); dal.Insert(gym); cityHall.Gyms.Add(gym); dal.Commit(); return(gym); }
/// <summary> /// Inserts into the database new instructorors and returns them. The id is based in the counter of persons in the system /// </summary> /// <param name="cityHall">The citiHall which containg the gym. It must be previously inserted in the dal</param> /// <returns>A collection with new instructors</returns> public ICollection <Instructor> InsertInstructors(int numberNewInstructors, CityHall cityHall) { ICollection <Instructor> newInstructors = new List <Instructor>(); for (int i = 0; i < numberNewInstructors; i++) { newInstructors.Add(InsertInstructor(cityHall)); } return(newInstructors); }
// Use this for initialization void Start() { cityHall = GetComponent <CityHall> (); if (string.IsNullOrEmpty(regionName)) { regionName = NameGen(); } if (mm == null) { mm = FindObjectOfType <MonthManager> (); } }
public override void AddInteractions(InteractionObjectPair iop, Sim actor, CityHall target, List<InteractionObjectPair> results) { string parent = Localization.LocalizeString(actor.IsFemale, "Gameplay/Objects/RabbitHoles/FutureCityHall/ScheduleFireworkShow:InteractionName", new object[] { CityHall.ScheduleFireworkShow.kCostOfFireworkShow }) + Localization.Ellipsis; float hour = SimClock.CurrentTime().Hour; for (int i = 0; i < CityHall.ScheduleFireworkShow.kTimeOptionsForFireworkShow.Length; i++) { if ((CityHall.ScheduleFireworkShow.kTimeOptionsForFireworkShow[i] - 1f) > hour) { results.Add(new InteractionObjectPair(new ScheduleFireworkDefinition(parent, Localization.LocalizeString(actor.IsFemale, "Gameplay/Objects/RabbitHoles/FutureCityHall/ScheduleFireworkShow:Time", new object[] { SimClockUtils.GetText(CityHall.ScheduleFireworkShow.kTimeOptionsForFireworkShow[i]) }), CityHall.ScheduleFireworkShow.kTimeOptionsForFireworkShow[i]), iop.Target)); } } }
public void ConstructorInitializesProps() { CityHall cityHall = new CityHall(TestData.EXPECTED_CITY_HALL_NAME); Assert.AreEqual(TestData.EXPECTED_CITY_HALL_NAME, cityHall.Name, "Name was not intialized properly. Check the order of the parameters and the assignment."); Assert.IsNotNull(cityHall.People, "The collection of People was not intialized properly.\nPatch the problem by adding: People = new List<Person>();"); Assert.IsNotNull(cityHall.Payments, "The collection of Payments was not intialized properly.\nPatch the problem by adding: Payments = new List<Payment>();"); Assert.IsNotNull(cityHall.Gyms, "The collection of Gyms was not intialized properly.\nPatch the problem by adding: Gyms = new List<Gym>();"); Assert.AreEqual(TestData.EXPECTED_EMPTY_LIST_COUNT, cityHall.People.Count, "The collection of People was not intialized properly.\nYou have added an extra element"); Assert.AreEqual(TestData.EXPECTED_EMPTY_LIST_COUNT, cityHall.Payments.Count, "The collection of Payments was not intialized properly.\nYou have added an extra element"); Assert.AreEqual(TestData.EXPECTED_EMPTY_LIST_COUNT, cityHall.Gyms.Count, "The collection of Gyms was not intialized properly.\nYou have added an extra element"); }
public void NoParametersConstructor() { CityHall cityHall = new CityHall(); Assert.AreNotSame(null, cityHall, "There must be a constructor without parameters"); Assert.IsNotNull(cityHall.People, "The collection of People was not intialized properly.\nPatch the problem by adding: People = new List<Person>();"); Assert.IsNotNull(cityHall.Payments, "The collection of Payments was not intialized properly.\nPatch the problem by adding: Payments = new List<Payment>();"); Assert.IsNotNull(cityHall.Gyms, "The collection of Gyms was not intialized properly.\nPatch the problem by adding: Gyms = new List<Gym>();"); Assert.AreEqual(TestData.EXPECTED_EMPTY_LIST_COUNT, cityHall.People.Count, "The collection of People was not intialized properly.\nYou have added an extra element"); Assert.AreEqual(TestData.EXPECTED_EMPTY_LIST_COUNT, cityHall.Payments.Count, "The collection of Payments was not intialized properly.\nYou have added an extra element"); Assert.AreEqual(TestData.EXPECTED_EMPTY_LIST_COUNT, cityHall.Gyms.Count, "The collection of Gyms was not intialized properly.\nYou have added an extra element"); }
public void Update() { if (worker.workState == WorkigState.WORKING && goldMine.workers.Count > 0) { goldMine.animations.Change("working"); elapsed += 0.1f; if (elapsed >= 10) { worker.workState = WorkigState.GO_TO_WORK; cityHall = managerBuildings.buildings.Find((b) => (b.information as InformationBuilding).Type == Util.Buildings.TOWN_HALL || (b.information as InformationBuilding).Type == Util.Buildings.GREAT_HALL) as CityHall; if (cityHall == null) { goldMine.Fire(); } else { if (currentState == State.MINER) { worker.Move((int)cityHall.Position.X / 32, (int)cityHall.Position.Y / 32); worker.animations.currentAnimation = Util.AnimationType.GOLD; goldMine.QUANITY -= 100; goldMine.animations.Change("normal"); currentState = State.TOWN_HALL; } else { worker.Move((int)goldMine.Position.X / 32, (int)goldMine.Position.Y / 32); worker.animations.currentAnimation = Util.AnimationType.WALKING; ManagerResources.ReduceGold(managerUnits.index, -100); if (goldMine.QUANITY <= 0) { goldMine.Fire(); } goldMine.animations.Change("working"); currentState = State.MINER; } } elapsed = 0; } } }
public void StoresPayment() { CityHall cityHall = new CityHall(TestData.EXPECTED_CITY_HALL_NAME); Payment payment = new Payment(TestData.EXPECTED_PAYMENT_DATE, TestData.EXPECTED_PAYMENT_DESCRIPCION, TestData.EXPECTED_PAYMENT_QUANTITY); cityHall.Payments.Add(payment); dal.Insert(cityHall); dal.Commit(); CityHall cityHallDAL = dal.GetAll <CityHall>().First(); Assert.IsNotNull(cityHallDAL.Payments, "The collection of Payments was not properly stored ."); Assert.AreEqual(TestData.EXPECTED_ONE_ELEMENT_LIST_COUNT, cityHallDAL.Payments.Count, "The collection of Payments was not properly stored.\n"); Assert.AreEqual(TestData.EXPECTED_PAYMENT_DESCRIPCION, cityHallDAL.Payments.First().Description, "The associated Payament is not properly stored\n"); }
public void CalculateEndGameBonus_Unocupplied() { //Arrange var cityHall = new CityHall(); cityHall.Occupation.Add(false); var playerBoard = new PlayerBoard(null); playerBoard.CitySpaces.Add(cityHall); //Act var result = cityHall.CalculateEndGameBonus(playerBoard); //Assert Assert.AreEqual(result, 0); }
public async Task <ActionResult> ConfirmRegister(Guid id) { CityHall cityHall = await _repository.GetById(id); if (cityHall == null) { return(NotFound()); } cityHall.Verified = true; await _repository.Update(cityHall); return(Ok()); }
public void StoresInitialData() { CityHall cityHall = new CityHall(TestData.EXPECTED_CITY_HALL_NAME); dal.Insert(cityHall); dal.Commit(); CityHall cityHallDAL = dal.GetAll <CityHall>().First(); Assert.AreEqual(TestData.EXPECTED_CITY_HALL_NAME, cityHallDAL.Name, "Name was not properly stored ."); Assert.IsNotNull(cityHallDAL.People, "The collection of People was not properly stored ."); Assert.IsNotNull(cityHallDAL.Payments, "The collection of Payments was not properly stored ."); Assert.IsNotNull(cityHallDAL.Gyms, "The collection of Gyms was not properly stored ."); Assert.AreEqual(TestData.EXPECTED_EMPTY_LIST_COUNT, cityHallDAL.People.Count, "The collection of People was not properly stored .\nThe number of elements is higher than expected."); Assert.AreEqual(TestData.EXPECTED_EMPTY_LIST_COUNT, cityHallDAL.Payments.Count, "The collection of Payments was not stored properly.\nThe number of elements is higher than expected."); Assert.AreEqual(TestData.EXPECTED_EMPTY_LIST_COUNT, cityHallDAL.Gyms.Count, "The collection of Gyms was not properly stored .\nThe number of elements is higher than expected."); }
public async Task Inactive(Guid cityHallId) { CityHall cityHall = await _repository.GetById(cityHallId); if (cityHall != null) { cityHall.Active = false; foreach (var item in await _userService.AllUsersByCityHallId(cityHallId)) { item.Active = false; await _userService.Update(item); } await _repository.Update(cityHall); } }
public void StoresPerson() { CityHall cityHall = new CityHall(TestData.EXPECTED_CITY_HALL_NAME); Person person = new Person(TestData.EXPECTED_PERSON_ADDRESS, TestData.EXPECTED_PERSON_IBAN, TestData.EXPECTED_PERSON_ID, TestData.EXPECTED_PERSON_NAME, TestData.EXPECTED_PERSON_ZIP_CODE); cityHall.People.Add(person); dal.Insert(cityHall); dal.Commit(); CityHall cityHallDAL = dal.GetAll <CityHall>().First(); Assert.IsNotNull(cityHallDAL.People, "The collection of People was not properly stored."); Assert.AreEqual(TestData.EXPECTED_ONE_ELEMENT_LIST_COUNT, cityHallDAL.People.Count, "The collection of People was not properly stored.\n"); Assert.AreEqual(TestData.EXPECTED_PERSON_ID, cityHallDAL.People.First().Id, " Th associated Person is not properly stored\n"); }
public void StoresGym() { CityHall cityHall = new CityHall(TestData.EXPECTED_CITY_HALL_NAME); Gym gym = new Gym(TestData.EXPECTED_GYM_CLOSING_HOUR, TestData.EXPECTED_GYM_DISCOUNT_LOCAL, TestData.EXPECTED_GYM_DISCOUNT_RETIRED, TestData.EXPECTED_GYM_FREE_USER_PRICE, TestData.EXPECTED_GYM_NAME, TestData.EXPECTED_GYM_OPENING_HOUR, TestData.EXPECTED_GYM_ZIP_CODE); cityHall.Gyms.Add(gym); dal.Insert(cityHall); dal.Commit(); CityHall cityHallDAL = dal.GetAll <CityHall>().First(); Assert.IsNotNull(cityHallDAL.Gyms, "The collection of Gyms was not properly stored ."); Assert.AreEqual(TestData.EXPECTED_ONE_ELEMENT_LIST_COUNT, cityHallDAL.Gyms.Count, "The collection of Gyms was not properly stored .\n"); Assert.AreEqual(TestData.EXPECTED_GYM_NAME, cityHallDAL.Gyms.First().Name, "The associated gym is not properly stored.\n"); }
public Gym gym; // Gym of the City Hall. Also available from cityHall.Gyms.First(); /// </summary> /// Returns a service Layer connected with the persistence Layer. Retrieves the CitiHall and Gym from the database if they exist. If not, it creates new ones /// </summary> /// <param name="dal"> Persistence Layer Interface</param> public GestDepService(IDAL dal) { this.dal = dal; try { if (dal.GetAll <CityHall>().Count() == 0) //No cityHall in the system. Data initilization. { bool CLEAR_DATABASE = true; int ROOMS_NUMBER = 9; int INSTRUCTORS_NUMBER = 5; Populate populateDB = new Populate(CLEAR_DATABASE, dal); cityHall = populateDB.InsertCityHall(); gym = populateDB.InsertGym(cityHall); //Also in cityHall.First(); populateDB.InsertRooms(ROOMS_NUMBER, gym); //Now available from gym.rooms; populateDB.InsertInstructors(INSTRUCTORS_NUMBER, cityHall); //Now available from cityHall.People; } else { //Retrieve the CityHall stored cityHall = dal.GetAll <CityHall>().First(); if (cityHall.Gyms.Count > 0) { //Retrieve the Gym stored gym = cityHall.Gyms.First(); } else { //Adding Rooms and Gym bool MANTAIN_DATABASE = false; int ROOMS_NUMBER = 9; Populate populateDB = new Populate(MANTAIN_DATABASE, dal); gym = populateDB.InsertGym(cityHall); populateDB.InsertRooms(ROOMS_NUMBER, gym); } int INSTRUCTORS_NUMBER = 5; if (dal.GetAll <Instructor>().Count() == 0)//No instructors { bool MANTAIN_DATABASE = false; Populate populateDB = new Populate(MANTAIN_DATABASE, dal); populateDB.InsertInstructors(INSTRUCTORS_NUMBER, cityHall); //Now available from cityHall.People; } } } catch (Exception e) { throw new ServiceException("Error in the service init process", e); } }
public override bool Test(Sim a, CityHall target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { if (!GameUtils.IsInstalled(ProductVersion.EP11)) { return(false); } if (a.FamilyFunds < CityHall.ScheduleFireworkShow.kCostOfFireworkShow) { greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(LocalizationHelper.InsufficientFunds); return(false); } if (target.mFireworkShowScheduled) { greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(Localization.LocalizeString(a.IsFemale, "Gameplay/Objects/RabbitHoles/FutureCityHall/ScheduleFireworkShow:AlreadyScheduled", new object[] { target.mFireworkSchedulerName, SimClockUtils.GetText(target.mFireworkScheduledTime) })); return(false); } return(true); }
private void createSampleDB(IDAL dal) { // Remove all data from DB dal.RemoveAllData(); CityHall ch = new CityHall("Valencia"); dal.Insert <CityHall>(ch); dal.Commit(); Gym g = new Gym(Convert.ToDateTime("14:00:00"), 5, 5, 2.00, "Gym1", Convert.ToDateTime("08:00:00"), 46022); dal.Insert <Gym>(g); ch.Gyms.Add(g); dal.Commit(); // Populate here the rest of the database with data }
void AddInstructors() { Console.WriteLine(); Console.WriteLine("ADDING INSTRUCTORS..."); try { CityHall c = service.FindCityHallByName("Valencia"); Gym g = c.FindGymByName("Gym1"); // Instructor(String address, String IBAN, String id, String name, int zipCode, String ssn) Instructor i = new Instructor("Xuan-Lan's address", "ES891234121234567891", "00000001R", "Xuan Lan", 46001, "SSN01010101"); c.AddPerson(i); service.AddInstructor(i); Activity a = g.FindActivityByName("Yoga 101"); a.SetInstructor(i); service.Commit(); Console.WriteLine(" " + a.Instructor.Name + " assigned to " + a.Description + " activity");; i = new Instructor("Mercedes de la Rosa's address", "ES891234121234567892", "00000002W", "Mercedes de la Rosa", 46002, "SSN02020202"); c.AddPerson(i); service.AddInstructor(i); i = new Instructor("Keila Velón's address", "ES891234121234567893", "00000003A", "Keila Velón", 46003, "SSN03030303"); c.AddPerson(i); service.AddInstructor(i); a = g.FindActivityByName("Zumba 101"); i = service.FindInstructorById("00000001R"); // Podría hacerse desde CityHall a.SetInstructor(i); service.Commit(); Console.WriteLine(" " + a.Instructor.Name + " assigned to " + a.Description + " activity");; } catch (Exception e) { printError(e); } }
void AddCityHallGymAndRooms() { Console.WriteLine(); Console.WriteLine("ADDING CITYHALL, GYM AND ROOMS..."); try { CityHall c = new CityHall("Valencia"); service.AddCityHall(c); //public Gym(DateTime closingHour, int discountLocal, int discountRetired, double freeUserPrice, String name, DateTime openingHour, int zipCode) Gym g = new Gym(Convert.ToDateTime("14:00:00"), 5, 5, 2.00, "Gym1", Convert.ToDateTime("08:00:00"), 46122); c.AddGym(g); for (int j = 1; j < 7; j++) { Room r = new Room(j); g.AddRoom(r); } service.AddGym(g); foreach (CityHall ci in service.GetAllCityHalls()) { Console.WriteLine("CityHall: " + ci.Name); foreach (Gym gy in ci.Gyms) { Console.WriteLine(" Gym: " + gy.Name); foreach (Room r in gy.Rooms) { Console.WriteLine(" Room: " + r.Number); } } } } catch (Exception e) { printError(e); } }
/// <summary> /// Inserts into the database one instructor and returns it. The id is based in the counter of persons in the system /// </summary> /// <param name="cityHall">The citiHall which containg the gym. It must be previously inserted in the dal</param> /// <returns>The new instructor</returns> public Instructor InsertInstructor(CityHall cityHall) { personCount++; string personId = personCount.ToString("D8"); //eight digits if (personId.Length <= 8) { char letter = NIFLetter(personId); personId = personId + letter;//adds the corresponding letter Instructor instructor = new Instructor(PERSON_ADDRESS + personCount, PERSON_IBAN, personId, PERSON_NAME + personCount, PERSON_ZIP_CODE, INSTRUCTOR_SSN); dal.Insert(instructor); cityHall.People.Add(instructor); dal.Commit(); return(instructor); } else { throw new ArgumentOutOfRangeException("only 8 digits required in DNI"); } }
public async Task <ActionResult> Add(CityHallInsertDto cityHall) { IEnumerable <CityHall> checkIfExists = await _repository.Find(c => c.CNPJ.Equals(cityHall.CNPJ)); if (checkIfExists.Count() > 0) { this.NotifyError($"O CNPJ {cityHall.CNPJ} já está cadastrado no sistema"); return(CustomResponse()); } CityHall newCityHall = _mapper.Map <CityHall>(cityHall); await _service.Add(newCityHall); var created = await _repository.GetById(newCityHall.Id); if (ValidOperation()) { return(CreatedAtAction(nameof(GetById), new { Id = newCityHall.Id, Version = "1.0" }, created)); } return(CustomResponse()); }
void TestingFreeRooms() { Console.WriteLine(); Console.WriteLine("TESTING FREE LANES"); try { CityHall c = service.FindCityHallByName("Valencia"); Gym g = c.FindGymByName("Gym1"); // Test free lanes week 2021, 3, 10 int freeLanes = g.GetFreeRooms(new DateTime(2021, 3, 10, 8, 00, 0), Days.Wed); Console.WriteLine(" Free lanes 10/03/21 at 8:00 - " + freeLanes); freeLanes = g.GetFreeRooms(new DateTime(2021, 3, 10, 9, 30, 0), Days.Wed); Console.WriteLine(" Free lanes 10/03/21 at 9:30 - " + freeLanes); } catch (Exception e) { printError(e); } }
public bool execute() { cityHall = managerBuildings.buildings.Find((b) => (b.information as InformationBuilding).Type == Util.Buildings.TOWN_HALL || (b.information as InformationBuilding).Type == Util.Buildings.GREAT_HALL) as CityHall; if (cityHall != null) { float maxDistance = float.MaxValue; for (int i = 0; i < ManagerBuildings.goldMines.Count; i++) { float distance = Vector2.Distance(ManagerBuildings.goldMines[i].Position, cityHall.Position); if (distance < maxDistance && ManagerBuildings.goldMines[i].QUANITY > 0) { maxDistance = distance; goldMine = ManagerBuildings.goldMines[i]; } } if (goldMine != null && goldMine.QUANITY > 0) { started = true; goldMine.workers.Add(worker as Builder); worker.workState = WorkigState.GO_TO_WORK; worker.Move((int)goldMine.Position.X / 32, (int)goldMine.Position.Y / 32); worker.selected = false; currentState = State.MINER; return(true); } } return(false); }
public async Task Update(CityHall cityHall) { await _repository.Update(cityHall); }
public AñadirUsuario(IGestDepService service, CityHall city) { InitializeComponent(); this.service = service; this.city = city; }
public override bool Test(Sim a, CityHall target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { if (!GameUtils.IsInstalled(ProductVersion.EP11)) { return false; } if (a.FamilyFunds < CityHall.ScheduleFireworkShow.kCostOfFireworkShow) { greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(LocalizationHelper.InsufficientFunds); return false; } if (target.mFireworkShowScheduled) { greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(Localization.LocalizeString(a.IsFemale, "Gameplay/Objects/RabbitHoles/FutureCityHall/ScheduleFireworkShow:AlreadyScheduled", new object[] { target.mFireworkSchedulerName, SimClockUtils.GetText(target.mFireworkScheduledTime) })); return false; } return true; }
public override string GetInteractionName(Sim actor, CityHall target, InteractionObjectPair iop) { return base.GetInteractionName(actor, target, new InteractionObjectPair(sOldSingleton, target)); }