public async Task <IActionResult> Edit(int id, [Bind("ID,Description,Price")] Convenience convenience) { if (id != convenience.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(convenience); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ConvenienceExists(convenience.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(convenience)); }
public static void ReplaceQuestIntroductionText() { if (NpcQuestList != null && NpcQuestList.Count > 0) { int firstX = 22; //선택지가 아무것도 없을때 첫 선택지의 위치 int lastY = 13; if (Convenience.DictionaryContainsValue(NpcCC.GetChoice("GreetPhase").IndicateChoice, "QuestIntroduction")) { NpcCC.RemoveChoiceSelectTextByValue("GreetPhase", "QuestIntroduction"); NpcCC.AddChoiceSelectText("GreetPhase", globalNPC.GetPreQuestMessage(), "QuestIntroduction"); } else { NpcCC.AddChoiceSelectText("GreetPhase", globalNPC.GetPreQuestMessage(), "QuestIntroduction"); } for (int i = 0; i < NpcQuestList.Count; i++) { if (!NpcQuestList[i].isAccept && !Convenience.DictionaryContainsValue(NpcCC.GetChoice("QuestIntroduction").IndicateChoice, NpcQuestList[i].QuestName)) { NpcCC.AddChoiceSelectText("QuestIntroduction", new TextAndPosition(NpcQuestList[i].QuestName, firstX, lastY + 1, true), NpcQuestList[i].QuestName); firstX = GameManager.selectListFirststPositionX(NpcCC.GetChoice("QuestIntroduction").SelectText); lastY = GameManager.selectListLastPositionY(NpcCC.GetChoice("QuestIntroduction").SelectText); } } } else { if (NpcCC.GetChoice("QuestIntroduction").SelectText.Count == 1) { NpcCC.RemoveChoiceSelectTextByValue("GreetPhase", "QuestIntroduction"); } } }
public async Task <IActionResult> Create([Bind("ID,Description,Price")] Convenience convenience) { if (ModelState.IsValid) { _context.Add(convenience); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(convenience)); }
public static Convenience ToModel(this ConvenienceViewModel viewModel) { if (viewModel != null) { Convenience model = new Convenience(); model.Id = viewModel.Id; model.Name = viewModel.Name; model.Rating = viewModel.Rating; return(model); } return(null); }
public static ConvenienceViewModel ToViewModel(this Convenience model) { if (model != null) { ConvenienceViewModel viewModel = new ConvenienceViewModel(); viewModel.Id = model.Id; viewModel.Name = model.Name; viewModel.Rating = model.Rating; return(viewModel); } return(null); }
public async Task <bool> ConnectedAsync() { var response = await Convenience.PingAsync(new PingRequest()); return(response.Result.Status == Status.Success); }
protected override void Seed(HotelDbContext context) { ApplicationRole role = new ApplicationRole { Name = "Admin" }; ApplicationRole role1 = new ApplicationRole { Name = "Manager" }; ApplicationRole role2 = new ApplicationRole { Name = "User" }; context.Roles.Add(role); context.Roles.Add(role1); context.Roles.Add(role2); context.SaveChanges(); ApplicationUserManager manager = new ApplicationUserManager(new UserStore <ApplicationUser>(context)); ApplicationUser user = new ApplicationUser { Email = "[email protected]", UserName = "******" }; ApplicationUser user1 = new ApplicationUser { Email = "[email protected]", UserName = "******" }; ApplicationUser user2 = new ApplicationUser { Email = "[email protected]", UserName = "******" }; manager.Create(user, "1234qweR!"); manager.AddToRole(user.Id, role.Name); manager.Create(user1, "!234qweR"); manager.AddToRole(user1.Id, role1.Name); manager.Create(user2, "!234qweR"); manager.AddToRole(user2.Id, role2.Name); Convenience conv1 = new Convenience { Name = "Большая кровать" }; Convenience conv2 = new Convenience { Name = "Мини-бар" }; Convenience conv3 = new Convenience { Name = "Джакузи" }; Convenience conv4 = new Convenience { Name = "Домашний кинотеатр" }; Convenience conv5 = new Convenience { Name = "Бассейн" }; context.Conveniences.AddRange(new List <Convenience> { conv1, conv2, conv3, conv4, conv5 }); context.SaveChanges(); RoomType type = new RoomType { Name = "Премиум", Description = "Отличный номер", Price = 200M, PathToImage = "/Content/img/1.jpg", Conveniences = new List <Convenience> { conv1, conv2, conv3 } }; RoomType type1 = new RoomType { Name = "Cтандарт", Description = "Отличный номер", Price = 100M, PathToImage = "/Content/img/2.jpg", Conveniences = new List <Convenience> { conv4, conv5, conv3 } }; RoomType type2 = new RoomType { Name = "Люкс", Description = "Отличный номер", Price = 150M, PathToImage = "/Content/img/3.jpg", Conveniences = new List <Convenience> { conv1, conv2, conv3, conv4 } }; context.RoomTypes.AddRange(new List <RoomType> { type, type1, type2 }); context.SaveChanges(); Room room = new Room { RoomNumber = 13, BedsCount = 1, RoomType = type }; Room room1 = new Room { RoomNumber = 14, BedsCount = 2, RoomType = type }; Room room2 = new Room { RoomNumber = 15, BedsCount = 2, RoomType = type }; Room room3 = new Room { RoomNumber = 16, BedsCount = 3, RoomType = type }; Room room4 = new Room { RoomNumber = 23, BedsCount = 2, RoomType = type1 }; Room room5 = new Room { RoomNumber = 24, BedsCount = 4, RoomType = type1 }; Room room6 = new Room { RoomNumber = 27, BedsCount = 2, RoomType = type2 }; Room room7 = new Room { RoomNumber = 28, BedsCount = 2, RoomType = type2 }; context.Rooms.AddRange(new List <Room> { room, room1, room2, room3, room4, room5, room6, room7 }); base.Seed(context); }
public async Task <int> UpdateAsync(Convenience updatedObject) { _context.Conveniences.Update(updatedObject); return(await _context.SaveChangesAsync()); }
public async Task <int> CreateAsync(Convenience newObject) { _context.Conveniences.Add(newObject); return(await _context.SaveChangesAsync()); }
public void TextArrangement() //Layout종류에 따라 Text들을 정렬 ChoiceControler에 Scenario를 넣을때 호출했다. { int firstX = 0; int lastY = 0; int count = 0; if (selectText != null) { for (int i = 0; i < selectText.Count; i++) //SelectText의 레이아웃 정렬 { TextAndPosition tap = selectText[i]; if (tap.Layout == null) { continue; } if (tap.Layout == TextLayout.SELECT_DEFAULT) { if (selectText.Count == 1) { tap[0] = 22; tap[1] = 13; } else { firstX = GameManager.selectListFirststPositionX(selectText); lastY = GameManager.selectListLastPositionY(selectText); tap[0] = firstX; tap[1] = lastY + ++count; } } } } if (selectText != null) { for (int i = 0; i < selectText.Count; i++) //SelectText중 CROSSROADS의 레이아웃 정렬 { TextAndPosition tap = selectText[i]; List <TextAndPosition> crossroads = new List <TextAndPosition>(); for (int j = 0; j < selectText.Count; j++) { if (selectText[i][1] >= 19) { crossroads.Add(selectText[i]); } } if (crossroads.Count != 0) { if (tap.Layout == TextLayout.CROSSROADS_DEFAULT) { if (crossroads.Count == 1) { tap[0] = 1; tap[1] = 19; } else if (crossroads.Count == 2) { firstX = 60 - (tap.text.Length + Convenience.GetKoreanCount(tap.text)); tap[0] = firstX; tap[1] = 19; } else if (crossroads.Count > 2) { throw new Exception("이미 갈림길이 2개 있음."); } } } } } if (onlyShowText != null) { for (int i = 0; i < onlyShowText.Count; i++) { TextAndPosition tap = onlyShowText[i]; if (tap.Layout == null) { continue; } if (tap.Layout == TextLayout.ONLY_SHOW_DEFAULT) { if (onlyShowText.Count == 1) { tap[0] = 15; tap[1] = 8; } else { firstX = GameManager.selectListFirststPositionX(onlyShowText); lastY = GameManager.selectListLastPositionY(onlyShowText); tap[0] = firstX; tap[1] = lastY; } } } } if (streamText != null) { for (int i = 0; i < streamText.Count; i++) { TextAndPosition tap = streamText[i]; if (tap.Layout == null) { continue; } if (tap.Layout == TextLayout.ONLY_SHOW_DEFAULT) { tap[0] = 15; tap[1] = 8; } } } if (returnText != null) { for (int i = 0; i < returnText.Count; i++) { TextAndPosition tap = returnText[i]; if (tap.Layout == null) { continue; } if (tap.Layout == TextLayout.ONLY_SHOW_DEFAULT) { if (returnText.Count == 1) { tap[0] = 15; tap[1] = 8; } else { firstX = GameManager.selectListFirststPositionX(returnText); lastY = GameManager.selectListLastPositionY(returnText); tap[0] = firstX; tap[1] = lastY; } } } } }
public async Task <ConvenienceViewModel> Get(int id) { Convenience convenience = await _service.getAsync(id); return(convenience.ToViewModel()); }
/// <summary> /// Program entry point /// </summary> /// <param name="args"></param> static void Main(string[] args) { #region preproceiing parsing the user inputs Console.WriteLine("Parsing given parameters..."); //Using the filename provided as the first argument string fileName = args[0]; //Using the years defined in the second argument string years = args[1]; string[] yearsSplit = years.Split(','); List <int> yearsList = new List <int>(); int temp; foreach (string y in yearsSplit) { if (int.TryParse(y, out temp)) { yearsList.Add(temp); } } //Using the pathways and mix id provided in the third argument string pm = args[2]; string[] pms = pm.Split(','); List <InputResourceReference> inRef = new List <InputResourceReference>(); foreach (string s in pms) { if (s[0] == 'p') {//this is a pathway reference if (int.TryParse(s.Substring(1, s.Length - 1), out temp)) { InputResourceReference pRef = new InputResourceReference(-1, temp, Enumerators.SourceType.Pathway); inRef.Add(pRef); } } else if (s[0] == 'm') {//this is a mix reference if (int.TryParse(s.Substring(1, s.Length - 1), out temp)) { InputResourceReference mRef = new InputResourceReference(-1, temp, Enumerators.SourceType.Mix); inRef.Add(mRef); } } } #endregion #region loading units file and data file Console.WriteLine("Building units context..."); //Build units context before loading the database Units.BuildContext(); Console.WriteLine("Loading datafile..."); //Loading the database GProject project = new GProject(); project.Load(fileName); #endregion #region preprocessing the pathways/mixes we want to record by finding their main output resource //Assign main output resource IDs to all the inputsResourceReferences foreach (InputResourceReference iref in inRef) { if (iref.SourceType == Greet.DataStructureV4.Interfaces.Enumerators.SourceType.Pathway) { if (project.Dataset.PathwaysData.ContainsKey(iref.SourceMixOrPathwayID)) { iref.ResourceId = project.Dataset.PathwaysData[iref.SourceMixOrPathwayID].MainOutputResourceID; } } else if (iref.SourceType == Greet.DataStructureV4.Interfaces.Enumerators.SourceType.Mix) { if (project.Dataset.MixesData.ContainsKey(iref.SourceMixOrPathwayID)) { iref.ResourceId = project.Dataset.MixesData[iref.SourceMixOrPathwayID].MainOutputResourceID; } } } #endregion #region running the calculations for each year and storing the results //Creating a new instance of a dictionary used to store results of the simulations Dictionary <InputResourceReference, Dictionary <int, Results> > savedResults = new Dictionary <InputResourceReference, Dictionary <int, Results> >(); //Running simulations for every provided years foreach (int simulationYear in yearsList) { Console.WriteLine("Running calculations for year " + simulationYear); //Set the current year for simulations BasicParameters.SelectedYear = project.Dataset.ParametersData.CreateUnregisteredParameter(project.Dataset, "", simulationYear); Calculator calc = new Calculator(); //Run the simulations for the loaded project and defined year, we need to wait completion as the RunCalculationMethod is Async var manualEvent = new ManualResetEvent(false); calc.CalculationDoneEvent += () => manualEvent.Set(); calc.RunCalculations(project); manualEvent.WaitOne(); //Loop over all the pathways and mixes ID that we wish to save foreach (InputResourceReference pathMixToSave in inRef) { if (!savedResults.ContainsKey(pathMixToSave)) { savedResults.Add(pathMixToSave, new Dictionary <int, Results>()); } if (!savedResults[pathMixToSave].ContainsKey(simulationYear)) { //Pull the results and add them to the dictionary used to store results Results results; if (pathMixToSave.SourceType == Enumerators.SourceType.Pathway) { results = Convenience.Clone(project.Dataset.PathwaysData[pathMixToSave.SourceMixOrPathwayID].getMainOutputResults().Results); } else { results = Convenience.Clone(project.Dataset.MixesData[pathMixToSave.SourceMixOrPathwayID].getMainOutputResults().Results); } savedResults[pathMixToSave].Add(simulationYear, results); } } } #endregion #region exporting all the results in a text file per pathway and per mix //Export all the desired results to an Excel spreadsheet Console.WriteLine("Export all selected results..."); string preferedMass = "g"; string preferedEnergy = "Btu"; string preferedVolume = "gal"; foreach (KeyValuePair <InputResourceReference, Dictionary <int, Results> > pair in savedResults) { DataTable dt = new DataTable(); List <string> resGroups = new List <string>() { "Total Energy", "Fossil Fuel", "Coal Fuel", "Natural Gas Fuel", "Petroleum Fuel", "Water" }; List <string> pollutants = new List <string>() { "VOC", "CO", "NOx", "PM10", "PM2.5", "SOx", "BC", "POC", "CH4", "N2O", "CO2", "CO2_Biogenic" }; List <string> polGroups = new List <string>() { "GHG-100" }; List <string> urbanPoll = new List <string>() { "VOC", "CO", "NOx", "PM10", "PM2.5", "SOx", "BC", "POC", "CH4", "N2O" }; Results resultsFU = pair.Value.Values.FirstOrDefault(); string functionalUnit = "Per "; if (resultsFU != null) { functionalUnit += GetPreferedVisualizationFunctionalUnitString(project.Dataset, resultsFU, pair.Key.ResourceId); } dt.Columns.Add("Items " + functionalUnit); foreach (int simulationYear in pair.Value.Keys) { dt.Columns.Add(simulationYear.ToString()); } List <string> rowString = new List <string>(); #region total energy and energy groups foreach (string resGrp in resGroups) { rowString = new List <string>(); if (resGrp == "Water") { rowString.Add(resGrp + " (" + preferedVolume + ")"); } else { rowString.Add(resGrp + " (" + preferedEnergy + ")"); } foreach (int simulationYear in pair.Value.Keys) { Results results = pair.Value[simulationYear]; double amountRatio = GetFunctionalRatio(project.Dataset, results, pair.Key.ResourceId); if (resGrp == "Total Energy") { LightValue totalE = results.wellToProductEnem.materialsAmounts.TotalEnergy(); rowString.Add(NiceValueWithAttribute(totalE * amountRatio, preferedEnergy)); } else { Dictionary <int, IValue> resGroupes = results.WellToProductResourcesGroups(project.Dataset); Group resGrpSelected = project.Dataset.ResourcesData.Groups.Values.SingleOrDefault(item => item.Name == resGrp); if (resGrpSelected != null) { int resGrpId = resGrpSelected.Id; LightValue groupValue = new LightValue(resGroupes[resGrpId].Value, resGroupes[resGrpId].UnitExpression); if (groupValue.Dim == DimensionUtils.ENERGY) { rowString.Add(NiceValueWithAttribute(groupValue * amountRatio, preferedEnergy)); } else { rowString.Add(NiceValueWithAttribute(groupValue * amountRatio, preferedVolume)); } } else { rowString.Add("0"); } } } dt.Rows.Add(rowString.ToArray()); } #endregion #region wtp emissions foreach (string poll in pollutants) { rowString = new List <string>(); rowString.Add(poll + " (" + preferedMass + ")"); foreach (int simulationYear in pair.Value.Keys) { Results results = pair.Value[simulationYear]; double amountRatio = GetFunctionalRatio(project.Dataset, results, pair.Key.ResourceId); int polId = project.Dataset.GasesData.Values.Single(item => item.Name == poll).Id; rowString.Add(NiceValueWithAttribute( new LightValue(results.wellToProductEnem.emissions[polId], DimensionUtils.MASS) * amountRatio , preferedMass)); } dt.Rows.Add(rowString.ToArray()); } #endregion #region wtp Groups (here only GHG 100) foreach (string resGrp in polGroups) { rowString = new List <string>(); rowString.Add(resGrp + " (" + preferedMass + ")"); foreach (int simulationYear in pair.Value.Keys) { Results results = pair.Value[simulationYear]; double amountRatio = GetFunctionalRatio(project.Dataset, results, pair.Key.ResourceId); Dictionary <int, IValue> emGroupes = pair.Value[simulationYear].WellToProductEmissionsGroups(project.Dataset); Group resGrpSelected = project.Dataset.GasesData.Groups.Values.SingleOrDefault(item => item.Name == resGrp); if (resGrpSelected != null) { int grpId = resGrpSelected.Id; rowString.Add(NiceValueWithAttribute(new LightValue(emGroupes[grpId].Value, emGroupes[grpId].UnitExpression) * amountRatio, preferedMass)); } else { rowString.Add("0"); } } dt.Rows.Add(rowString.ToArray()); } #endregion #region urban emissions foreach (string poll in pollutants) { rowString = new List <string>(); rowString.Add("Urban " + poll + " (" + preferedMass + ")"); foreach (int simulationYear in pair.Value.Keys) { Results results = pair.Value[simulationYear]; double amountRatio = GetFunctionalRatio(project.Dataset, results, pair.Key.ResourceId); int polId = project.Dataset.GasesData.Values.Single(item => item.Name == poll).Id; rowString.Add(NiceValueWithAttribute(new LightValue(results.wellToProductUrbanEmission[polId], DimensionUtils.MASS) * amountRatio, preferedMass)); } dt.Rows.Add(rowString.ToArray()); } #endregion string value = ConvertDataTableToString(dt); System.IO.File.WriteAllText("Results-" + pair.Key.SourceType.ToString() + "-" + pair.Key.SourceMixOrPathwayID.ToString() + ".txt", value); } #endregion }