/// <summary> /// Get all Tax value /// </summary> /// <returns></returns> public ApiResponseViewModel GetAll() { var result = new List <TypeViewModel>(); var response = new ApiResponseViewModel { Code = CommonConstants.ApiResponseSuccessCode, Message = null, Result = null }; try { result = _TypeRepository.GetAll().Where(m => m.IsActive == true).Select(m => new TypeViewModel { ID = m.ID, TypeName = m.TypeName, IsActive = m.IsActive ?? false }).ToList(); response.Result = result; } catch (Exception ex) { response.Code = CommonConstants.ApiResponseExceptionCode; response.Message = CommonConstants.ErrorMessage + " " + ex.Message; } return(response); }
public IActionResult List() { BookModel model = new BookModel(); model.BookList = bookRepository.GetAll().ToList(); model.AuthorList = authorRepository.GetAll().ToList(); model.TypeList = typeRepository.GetAll().ToList(); return(View(model)); }
public IActionResult Index() { if (HttpContext.Session.GetString("user") is null) { Response.Redirect("/admin/login"); } ViewBag.User = HttpContext.Session.GetString("user"); var types = _repository.GetAll(); return(View(types)); }
public async Task <ICollection <Type> > GetAll(User user) { try { return(_typeRepository.GetAll().Where(x => (x.fk_UserId == user.Id || x.fk_UserId == null) && !x.Deleted).ToList()); } catch (Exception ex) { throw; } }
public AppQuery( IOwnerRepository ownerRepository, IAccountRepository accountRepository, ITypeRepository typeRepository) { Field <ListGraphType <OwnerType> >( "owners", resolve: context => ownerRepository.GetAll()); Field <OwnerType>( "owner", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "ownerId" }), resolve: context => { if (!int.TryParse(context.GetArgument <string>("ownerId"), out int id)) { context.Errors.Add(new ExecutionError("Wrong value for Id")); return(null); } return(ownerRepository.GetById(id)); } ); Field <ListGraphType <AccountType> >( "account", resolve: context => accountRepository.GetAll()); Field <ListGraphType <TypeType> >( "type", resolve: context => typeRepository.GetAll()); }
public IActionResult Index() { CheckRooms reservation = new CheckRooms() { RoomTypes = new SelectList(_typeRepository.GetAll(), "TypeId", "TypeName") }; return(View(reservation)); }
public Task <IEnumerable <SubscriptionType> > Get() { try { return(_typeRepository.GetAll()); } catch (Exception ex) { _log.LogError(ex.ToString()); return(null); } }
public static ITypeRepository Extend(this ITypeRepository target, ITypeRepository source) { _ = target ?? throw new ArgumentNullException(nameof(target)); _ = source ?? throw new ArgumentNullException(nameof(source)); foreach (var item in source.GetAll() ?? Enumerable.Empty <KeyValuePair <Type, Type> >()) { if (!target.TryGet(item.Key, out _)) { target.Add(item.Key, item.Value); } } return(target); }
public IActionResult PieChart() { var books = bookRepository.GetAll(); //PASTA GRAFİĞİ TÜRÜNE GÖRE var allCategory = typeRepository.GetAll(); List <DataPoint> dataPoints = new List <DataPoint>(); var readedBook = books.Where(i => i.isReaded == true).Count(); for (int i = 1; i <= allCategory.Count(); i++) { var category = typeRepository.GetById(i); int book = books.Where(a => a.isReaded == true).Where(a => a.TypeId == i).Count(); int rate = 100 * book / readedBook; dataPoints.Add(new DataPoint(category.Name, rate)); } ViewBag.DataPoints = JsonConvert.SerializeObject(dataPoints); //PASTA GRAFİĞİ TÜRÜNE GÖRE SON return(View()); }
public async Task SeedsAsync() { using (var client = new HttpClient()) { client.BaseAddress = new Uri(_apiUrl); var types = _typeRepository.GetAll(); List <TypeAdvantage> typeAdvantages = new List <TypeAdvantage>(); foreach (var type in types) { List <TypeAdvantage> typeAdvantagesByType = new List <TypeAdvantage>(); var errorCount = 0; var serviceSuccess = false; HttpResponseMessage results; do { var responseTask = client.GetAsync(string.Concat("type/", type.Name.ToLower())); responseTask.Wait(); results = responseTask.Result; serviceSuccess = results.IsSuccessStatusCode; errorCount++; if (errorCount == 3) { throw new PokeApiException(); } } while (!serviceSuccess); string apiResponse = await results.Content.ReadAsStringAsync(); var json = JObject.Parse(apiResponse); var damageRelations = json["damage_relations"]; var doubleDamageTo = damageRelations["double_damage_to"]; var halfDamageTo = damageRelations["half_damage_to"]; var noDamageTo = damageRelations["no_damage_to"]; foreach (var typeDoubleDamageTo in doubleDamageTo) { var name = typeDoubleDamageTo["name"].ToString(); var idDefensiveType = types.First(x => x.Name.ToLower() == name.ToLower()).Id; typeAdvantagesByType.Add(new TypeAdvantage(idAttackingType: type.Id, idDefensiveType: idDefensiveType, effect: 2)); } foreach (var typeHaldDamageTo in halfDamageTo) { var name = typeHaldDamageTo["name"].ToString(); var idDefensiveType = types.First(x => x.Name.ToLower() == name.ToLower()).Id; typeAdvantagesByType.Add(new TypeAdvantage(idAttackingType: type.Id, idDefensiveType: idDefensiveType, effect: 0.5m)); } foreach (var typeNoDamageTo in noDamageTo) { var name = typeNoDamageTo["name"].ToString(); var idDefensiveType = types.First(x => x.Name.ToLower() == name.ToLower()).Id; typeAdvantagesByType.Add(new TypeAdvantage(idAttackingType: type.Id, idDefensiveType: idDefensiveType, effect: 0m)); } var neutralDamageTo = types.Where(x => !typeAdvantagesByType.Exists(y => x.Id == y.IdDefensiveType)); foreach (var defendingType in neutralDamageTo) { typeAdvantagesByType.Add(new TypeAdvantage(idAttackingType: type.Id, idDefensiveType: defendingType.Id, effect: 1m)); } typeAdvantages.AddRange(typeAdvantagesByType); } foreach (var typeAdvantage in typeAdvantages) { _typeAdvantageRepository.Create(typeAdvantage); } } }
public async Task SeedsAsync(int initialIndex) { int pokemonNationalNumb = initialIndex; try { using (var client = new HttpClient()) { client.BaseAddress = new Uri(_apiUrl); var allTypes = _typeRepository.GetAll(); for (int i = initialIndex; i <= 807; i++) { pokemonNationalNumb = i; HttpResponseMessage results; bool responseSuccess = false; int errorCount = 0; do { var responseTask = client.GetAsync(string.Concat("pokemon/", i)); responseTask.Wait(); results = responseTask.Result; responseSuccess = results.IsSuccessStatusCode; if (!responseSuccess) { errorCount++; } if (errorCount == 3) { throw new PokeApiException(); } } while(!responseSuccess); string apiResponse = await results.Content.ReadAsStringAsync(); var json = JObject.Parse(apiResponse); var name = json["forms"][0]["name"].ToString(); var stats = json["stats"]; var types = json["types"]; var firstType = allTypes.FirstOrDefault(x => x.Name.ToLower() == types[0]["type"]["name"].ToString().ToLower()); var secondType = new Models.Type(); var pokemonSpecies = new Pokemon_Species() { National_Numb = i, Name = name, Base_Hp = (int)stats[5]["base_stat"], Base_Attack = (int)stats[4]["base_stat"], Base_Defense = (int)stats[3]["base_stat"], Base_Sp_Attack = (int)stats[2]["base_stat"], Base_Sp_Defense = (int)stats[1]["base_stat"], Base_Speed = (int)stats[0]["base_stat"], First_Type_Id = firstType.Id, }; if (types.Count() > 1) { secondType = allTypes.FirstOrDefault(x => x.Name.ToLower() == types[1]["type"]["name"].ToString().ToLower()); pokemonSpecies.Second_Type_Id = secondType.Id; } _pokemonRepository.Create(pokemonSpecies); } } } catch (Exception ex) { using (var logger = LoggerDomain.GetLog(_connectionString)) { logger.Error(string.Format("Error at pokemonSpecies {0} - Exception Message: ", pokemonNationalNumb, ex.Message)); throw ex; } } }
public IActionResult List() { return(View(typeRepository.GetAll())); }
public IEnumerable <Models.Type> Get() { return(_typeRepository.GetAll()); }
public IList <TypeViewModel> GetAll() { IList <Type> types = _typeRepository.GetAll().ToList(); return(this.GenerateTypeViewModels(types)); }
public void Should_GetAll_Return_all_indexes_Types() { IEnumerable <Type> _types = _typeRepository.GetAll(); Assert.IsTrue(_types.Count() > 0); }
public IEnumerable <TypeEntity> Get() { return(_typeRepository.GetAll()); }
public async Task SeedsAsync(int initialIndex) { var typeLists = _typeRepository.GetAll(); int moveIndex = initialIndex; try { using (var client = new HttpClient()) { client.BaseAddress = new Uri(_apiUrl); for (int i = initialIndex; i <= 728; i++) { moveIndex = i; HttpResponseMessage results; bool responseSuccess = false; int errorCount = 0; do { var responseTask = client.GetAsync(string.Concat("move/", i)); responseTask.Wait(); results = responseTask.Result; responseSuccess = results.IsSuccessStatusCode; if (!responseSuccess) { errorCount++; } if (errorCount == 3) { throw new PokeApiException(); } } while (responseSuccess == false); string apiResponse = await results.Content.ReadAsStringAsync(); var json = JObject.Parse(apiResponse); var name = json["names"][2]["name"].ToString(); var basePowerString = json["power"].ToString(); var moveTypeString = json["type"]["name"].ToString(); var moveCategoryString = json["damage_class"]["name"].ToString(); var basePower = basePowerString.ToDecimal(); var moveType = typeLists.FirstOrDefault(x => x.Name.ToLower() == moveTypeString); var moveCategory = (MoveCategoryEnum)typeof(MoveCategoryEnum).GetEnumByDescription(moveCategoryString); if (moveCategory == MoveCategoryEnum.Status) { continue; } var move = new Moves() { Name = name, Base_Power = basePower, Move_Category = moveCategory, Id_Type = moveType.Id }; _moveRepository.Create(move); } } } catch (Exception ex) { using (var logger = LoggerDomain.GetLog(_connectionString)) { logger.Error(string.Format("Error at pokemonSpecies {0} - Exception Message: ", moveIndex, ex.Message)); throw ex; } } }
public IActionResult GetTypes() { var types = _typeRepository.GetAll(); return(new OkObjectResult(types)); }
public IEnumerable <TypeDTO> GetAll() { return(_typeRepository.GetAll()); }
public IViewComponentResult Invoke() { ViewBag.SelectedType = RouteData?.Values["id"]; return(View(_repository.GetAll())); }