public IEnumerable <ClassQuestTask> Parse(Stream resource, Seedling seedling, ref int id) { var tasks = new List <ClassQuestTask>(); var ctr = id; var parse = ParseResource <ClassQuestParse>(resource); tasks.AddRange(parse.Select((x, index) => { return(new ClassQuestTask { Id = ++ctr, Name = x.Name, CategoryId = SeedCategories .GetCategoryId( ((ClassQuestSeedling)seedling).ParentCategory, x.Discipline ), Level = int.Parse(x.Level), DisciplineId = SeedCommon.GetDisciplineId(x.Discipline) }); })); id = ctr; return(tasks); }
public IEnumerable <FATETask> Parse(Stream resource, Seedling seedling, ref int id) { var tasks = new List <FATETask>(); var ctr = id; var parse = ParseResource <FATEParse>(resource); tasks.AddRange(parse.Select((x, index) => { var location = SplitLocation(x.Location); return(new FATETask { Id = ++ctr, CategoryId = seedling.CategoryId, Name = x.Name, Level = x.Level, Location = location.Name, X = location.Coordinates != null ? location.Coordinates.X : -1.0M, Y = location.Coordinates != null ? location.Coordinates.Y : -1.0M }); })); id = ctr; return(tasks); }
public IEnumerable <SightseeingLogTask> Parse(Stream resource, Seedling seedling, ref int id) { var tasks = new List <SightseeingLogTask>(); var ctr = id; var parse = ParseResource <SightseeingLogParse>(resource); tasks.AddRange(parse.Select((x, index) => { var task = new SightseeingLogTask { Id = ++ctr, Name = x.Name, Number = x.Number, Weather = x.Weather, Time = x.Time, Emote = x.Emote, CategoryId = seedling.CategoryId, PatchId = SeedCommon.GetMajorPatchId(x.Set) }; return(task); })); id = ctr; return(tasks); }
public void AddSeedling(HttpRequestMessage request, [FromBody] Seedling seedling) { using (var context = new PlantAppContext()) { context.Seedlings.Add(seedling); context.SaveChanges(); } }
public async Task <IActionResult> Create(Seedling seedling) { if (ModelState.IsValid) { await _repo.AddAsync(seedling); return(RedirectToAction("Index")); } return(View(seedling)); }
public async void CreatePostAction_SaveModel() { // arrange var mock = new Mock <IRepository <Seedling> >(); var seedling = new Seedling(); var controller = new SeedlingsController(mock.Object); // act RedirectToRouteResult result = await controller.Create(seedling) as RedirectToRouteResult; // assert mock.Verify(a => a.AddAsync(seedling)); }
public static SeedlingDTO FromEntity(Seedling seedling) { return(new SeedlingDTO { Id = seedling.Id, Name = seedling.Name, Plants = seedling.Plants.ToList().Select(x => new Plant() { Id = x.Id, PlantSpecie = new PlantSpecie() { Id = x.PlantSpecie.Id, Color = x.PlantSpecie.Color, MaintenceGuide = x.PlantSpecie.MaintenceGuide, MinimalWaterAmountForWatering = x.PlantSpecie.MinimalWaterAmountForWatering, MonthsOfFlowering = x.PlantSpecie.MonthsOfFlowering, Name = x.PlantSpecie.Name, Plants = null, WateringFrequencyDays = x.PlantSpecie.WateringFrequencyDays }, Seedling = null }).ToList() }); }
public async void AddSeedlingReturnsViewResultWithSeedlingModel() { // Arrange var mock = new Mock <IRepository <Seedling> >(); var controller = new SeedlingsController(mock.Object); controller.ModelState.AddModelError("Name", "Required"); Seedling newSeedling = new Seedling(); // Act var result = await controller.Create(newSeedling); // Assert var viewResult = Assert.IsType <ViewResult>(result); Assert.Equal(newSeedling, viewResult?.Model); }
public IEnumerable <FishGuideTask> Parse(Stream resource, Seedling seedling, ref int id) { var tasks = new List <FishGuideTask>(); var ctr = id; var parse = ParseResource <FishGuideParse>(resource); tasks.AddRange(parse.Select((x, index) => { return(new FishGuideTask { Id = ++ctr, CategoryId = seedling.CategoryId, Name = x.Name, Bait = x.Bait, ILevel = x.Level, ZoneId = SeedCommon.GetZoneId(x.Zone) }); })); return(tasks); }
public IEnumerable <PvETask> Parse(Stream resource, Seedling seedling, ref int id) { var tasks = new List <PvETask>(); var ctr = id; var parse = ParseResource <PvEParse>(resource); tasks.AddRange(parse.Select((x, index) => { return(new PvETask { Id = ++ctr, Name = x.Name, CategoryId = seedling.CategoryId, ContentId = SeedCommon.GetContentId(x.Name) }); })); id = ctr; return(tasks); }
public IEnumerable <RoleQuestTask> Parse(Stream resource, Seedling seedling, ref int id) { var tasks = new List <RoleQuestTask>(); var ctr = id; var parse = ParseResource <RoleQuestParse>(resource); tasks.AddRange(parse.Select((x, index) => { return(new RoleQuestTask { Id = ++ctr, Name = x.Name, CategoryId = seedling.CategoryId, JobRoleId = SeedCommon.GetJobRoleId(x.Role), Level = int.Parse(x.Level) }); })); id = ctr; return(tasks); }
public async void AddSeedlingReturnsARedirectAndAddsSeedling() { // Arrange var mock = new Mock <IRepository <Seedling> >(); var controller = new SeedlingsController(mock.Object); var newSeedling = new Seedling() { Name = "pear", Price = 100, Amount = 100 }; // Act var result = await controller.Create(newSeedling); // Assert var redirectToActionResult = Assert.IsType <RedirectToActionResult>(result); Assert.Null(redirectToActionResult.ControllerName); Assert.Equal("Index", redirectToActionResult.ActionName); mock.Verify(r => r.AddAsync(newSeedling)); }
public IEnumerable <SQTask> Parse(Stream resource, Seedling seedling, ref int id) { var tasks = new List <SQTask>(); var ctr = id; var parse = ParseResource <SQTaskParse>(resource); tasks.AddRange(parse.Select((x, index) => { return(new SQTask { Id = ++ctr, Name = x.Name, CategoryId = seedling.CategoryId, Level = int.Parse(x.Level), SQTypeId = SeedCommon.GetSQTypeId(((SidequestSeedling)seedling).TypeName) }); })); id = ctr; return(tasks); }
private void UpdatePreviewTexture() { List <Color> pixels = new List <Color>(); Seedling seedling = (Seedling)target; for (int x = 0; x < PREVIEW_SIZE; x++) { for (int y = 0; y < PREVIEW_SIZE; y++) { float pixelValue = seedling.Sample(x, y); Color pixelColor = new Color(pixelValue, pixelValue, pixelValue, 1); pixels.Add(pixelColor); } } previewTexture.SetPixels(pixels.ToArray()); previewTexture.Apply(); }
public IEnumerable <OpponentTask> Parse(Stream resource, Seedling seedling, ref int id) { var tasks = new List <OpponentTask>(); var ctr = id; var parse = ParseResource <OpponentParse>(resource); tasks.AddRange(parse.Select((x, index) => { return(new OpponentTask { Id = ++ctr, Name = x.Name, CategoryId = seedling.CategoryId, Location = x.Location, Zone = x.Zone }); })); id = ctr; return(tasks); }
public IEnumerable <LeveTask> Parse(Stream resource, Seedling seedling, ref int id) { var tasks = new List <LeveTask>(); var ctr = id; var parse = ParseResource <LeveParse>(resource); tasks.AddRange(parse.Select((x, index) => { return(new LeveTask { Id = ++ctr, Name = x.Name, CategoryId = seedling.CategoryId, Level = x.Level, LeveTypeId = SeedCommon.GetLeveTypeId(x.Type), NPCName = x.NPC }); })); id = ctr; return(tasks); }
public IEnumerable <CardTask> Parse(Stream resource, Seedling seedling, ref int id) { var tasks = new List <CardTask>(); var ctr = id; var parse = ParseResource <CardParse>(resource); tasks.AddRange(parse.Select((x, index) => { return(new CardTask { Id = ++ctr, Name = x.Name, NPCName = x.NPC, CategoryId = seedling.CategoryId, OtherMethods = x.OtherMethods, Rank = int.Parse(x.Rank) }); })); id = ctr; return(tasks); }
public IEnumerable <OrchestrionTask> Parse(Stream resource, Seedling seedling, ref int id) { var tasks = new List <OrchestrionTask>(); var ctr = id; var parse = ParseResource <OrchestrionParse>(resource); tasks.AddRange(parse.Select((x, index) => { return(new OrchestrionTask { Id = ++ctr, Name = x.Name, CategoryId = seedling.CategoryId, Method = x.Method, Number = x.Number, OrchestrionTypeId = ((OrchestrionSeedling)seedling).OrchestrionTypeId }); })); id = ctr; return(tasks); }
public IEnumerable <GatheringLogTask> Parse(Stream resource, Seedling seedling, ref int id) { var tasks = new List <GatheringLogTask>(); var ctr = id; var parse = ParseResource <GatheringLogParse>(resource); tasks.AddRange(parse.Select((x, index) => { return(new GatheringLogTask { Id = ++ctr, Name = x.Name, CategoryId = seedling.CategoryId, Level = x.Level, Location = x.Location, GatherTypeId = ((GatheringLogSeedling)seedling).GatherTypeId }); })); id = ctr; return(tasks); }
public IEnumerable <BeastQuestTask> Parse(Stream resource, Seedling seedling, ref int id) { var tasks = new List <BeastQuestTask>(); var ctr = id; var parse = ParseResource <BeastQuestParse>(resource); tasks.AddRange(parse.Select((x, index) => { return(new BeastQuestTask { Id = ++ctr, Name = x.Name, Level = int.Parse(x.Level), BeastRankId = SeedCommon.BeastRanks.GetMatchId <BeastRank>(x.Rank), BeastTribeId = SeedCommon.BeastTribes.GetMatchId <BeastTribe>(x.Tribe), CategoryId = SeedCategories.GetCategoryId(x.Tribe) }); })); id = ctr; return(tasks); }
public IEnumerable <MSQTask> Parse(Stream resource, Seedling seedling, ref int id) { var tasks = new List <MSQTask>(); var ctr = id; var parse = ParseResource <MSQTaskParse>(resource); tasks.AddRange(parse.Select((x, index) => { var task = new MSQTask { Id = ++ctr, Name = x.Name, CategoryId = seedling.CategoryId, MSQTypeId = SeedCommon.GetMSQTypeId(((MSQSeedling)seedling).MSQTypeName), Level = x.Level, }; return(task); })); id = ctr; return(tasks); }
public IEnumerable <RelicWeaponTask> Parse(Stream resource, Seedling seedling, ref int id) { var tasks = new List <RelicWeaponTask>(); var ctr = id; var sdling = ((RelicWeaponSeedling)seedling); switch (sdling.Category.ToLower()) { case "zodiac": var zParse = ParseResource <ZodiacWeaponParse>(resource); foreach (var z in zParse) { tasks.AddRange( CreateRelicWeaponTasks( ref ctr, seedling.CategoryId, SeedCommon.GetDisciplineIdByAbbreviation(z.Discipline), z.FirstName, z.SecondName ) ); } break; case "anima": var aParse = ParseResource <AnimaWeaponParse>(resource); foreach (var a in aParse) { tasks.AddRange( CreateRelicWeaponTasks( ref ctr, seedling.CategoryId, SeedCommon.GetDisciplineIdByAbbreviation(a.Discipline), a.FirstName, a.SecondName, a.ThirdName, a.FourthName ) ); } break; case "eurekan": var eParse = ParseResource <EurekanWeaponParse>(resource); foreach (var e in eParse) { tasks.AddRange( CreateRelicWeaponTasks( ref ctr, seedling.CategoryId, SeedCommon.GetDisciplineIdByAbbreviation(e.Discipline), e.AnemosName, string.Concat("Elemental ", e.ElementalPyrosName), e.PhyseosName ) ); } break; default: break; } id = ctr; return(tasks); }
protected override void Seed(PlantAppContext context) { var plantSpecie1 = new PlantSpecie() { Name = "prva vrsta", WateringFrequencyDays = 3000, MinimalWaterAmountForWatering = 10, Color = "Blue", MonthsOfFlowering = "12,3,4,5", MaintenceGuide = "ne gaziti" }; var plantSpecie2 = new PlantSpecie() { Name = "druga vrsta", WateringFrequencyDays = 50, MinimalWaterAmountForWatering = 20, Color = "Red", MonthsOfFlowering = "1,2,3,4,5", MaintenceGuide = "nista posebno" }; var seedling1 = new Seedling() { Name = "prva sadnica", Plants = new List <Plant> { } }; var seedling2 = new Seedling() { Name = "druga sadnica" }; var plant1 = new Plant() { PlantSpecie = plantSpecie1, Seedling = seedling1, TimeAndDateLastWatered = DateTime.Now, }; var plant2 = new Plant() { PlantSpecie = plantSpecie2, Seedling = seedling1, TimeAndDateLastWatered = DateTime.Now }; var plant3 = new Plant() { PlantSpecie = plantSpecie1, Seedling = seedling2, TimeAndDateLastWatered = DateTime.Now }; seedling1.Plants = new List <Plant> { plant1, plant2 }; seedling2.Plants = new List <Plant>() { plant3 }; context.PlantSpecies.Add(plantSpecie1); context.PlantSpecies.Add(plantSpecie2); context.Plants.Add(plant1); context.Plants.Add(plant2); context.Plants.Add(plant3); context.Seedlings.Add(seedling1); context.Seedlings.Add(seedling2); context.SaveChanges(); base.Seed(context); }
public async Task <IActionResult> Edit(Seedling seedling) { await _repo.UpdateAsync(seedling); return(RedirectToAction("Index")); }
public IEnumerable <HuntingLogTask> Parse(Stream resource, Seedling seedling, ref int id) { var tasks = new List <HuntingLogTask>(); var ctr = id; var parse = ParseResource <HuntingLogParse>(resource); var mobId = 1; tasks.AddRange(parse.Select((x, index) => { var task = new HuntingLogTask { Id = ++ctr, Name = x.Record, CategoryId = seedling.CategoryId, HuntingLogTypeId = SeedCommon.GetHuntingLogTypeId(x.Record.Split(' ')[0]), Level = x.Level, Number = x.Record.Split(' ')[x.Record.Split(' ').Length - 1] }; var mobNames = x.Mobs.Split(','); var zoneNames = x.Zone.Split(','); var locationNames = x.Location.Split(';'); var mobs = new List <HuntingLogMob>(); for (var i = 0; i < mobNames.Count(); i++) { var name = ""; var zoneName = ""; var location = ""; var locationName = ""; var coordinates = new string[] { "" }; try { name = mobNames[i].Trim(); zoneName = zoneNames.Length >= i + 1 ? zoneNames[i].Trim() : zoneNames[zoneNames.Length - 1].Trim(); location = locationNames.Length >= i + 1 ? locationNames[i].Trim() : locationNames[locationNames.Length - 1].Trim(); locationName = location.Split('(')[0].Trim(); coordinates = location.Split('(', ')').Length > 1 ? location.Split('(', ')')[1].Split(',') : new string[] { "-1", "-1" }; mobs.Add(new HuntingLogMob { Id = mobId++, Name = name, Zone = zoneName, Location = locationName, X = decimal.Parse(coordinates[0]), Y = decimal.Parse(coordinates[1]), HuntingLogId = ctr }); } catch (Exception ex) { throw new Exception(string.Format("Exception item: {0}", mobNames[0])); } //catch(FormatException ex) //{ // throw new Exception(string.Format("Format Exception. Name: {0}, X: {1}, Y: {2}", name, coordinates[0].Trim(), coordinates[1].Trim())); //} //catch(IndexOutOfRangeException ex) //{ // throw new Exception(string.Format("Index Out Of Range. i: {0}, NameLength: {1}, ZoneLength: {2}, LocationLength: {3}", // i, mobNames.Length, zoneNames.Length, locationNames.Length)); //} } task.Mobs = mobs; return(task); })); id = ctr; return(tasks); }
public static IEnumerable <CollectionTask> ParseCollectionTasks(Stream resource, Seedling seedling, ref int id) { var tasks = new List <CollectionTask>(); var ctr = id; var parse = Parse <CollectionParse>(resource); tasks.AddRange(parse.Select((x, index) => new CollectionTask { Id = ++ctr, CategoryId = seedling.CategoryId, CollectionTypeId = SeedCommon.GetCollectionTypeIndex(seedling.FileName), Name = x.Name, Method = x.Method })); id = ctr; return(tasks); }