Example #1
0
        public async Task <IActionResult> Edit(int id, BikeTypeEntity bikeTypeEntity)
        {
            if (id != bikeTypeEntity.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(bikeTypeEntity);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BikeTypeEntityExists(bikeTypeEntity.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(bikeTypeEntity));
        }
Example #2
0
        private async Task <BikeTypeEntity> CheckBikeTypeAsync(string name)
        {
            var type = new BikeTypeEntity {
                Name = name
            };
            await _dataContext.BikeTypes.AddAsync(type);

            await _dataContext.SaveChangesAsync();

            return(type);
        }
Example #3
0
        public async Task <IActionResult> Create(BikeTypeEntity bikeTypeEntity)
        {
            if (ModelState.IsValid)
            {
                _context.Add(bikeTypeEntity);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(bikeTypeEntity));
        }
Example #4
0
        public void GetBikeType_Returns_BikeTypeDto()
        {
            var id     = 1;
            var entity = new BikeTypeEntity();
            var dto    = new BikeTypeDto();

            mockRepo.Setup(r => r.GetById(It.IsAny <int>())).Returns(entity);
            mockMapper.Setup(m => m.Map <BikeTypeDto>(entity)).Returns(dto);
            BikeTypeDto actual = bikeTypeService.GetBikeType(id);

            Assert.AreEqual(actual, dto);
        }
Example #5
0
        public static BikeTypeEntity Map(this BikeType bikeTypeModel)
        {
            if (bikeTypeModel == null)
            {
                return(null);
            }
            BikeTypeEntity bikeType = new BikeTypeEntity
            {
                ID       = bikeTypeModel.ID,
                TypeName = bikeTypeModel.TypeName
            };

            return(bikeType);
        }
Example #6
0
        private async Task <TypeMakerEntity> CkeckTypeMakerAsync(BikeMakerEntity maker, BikeTypeEntity type)
        {
            var TypeMake = new TypeMakerEntity
            {
                BikeMaker = maker,
                BikeType  = type,
            };

            await _dataContext.TypeMakers.AddAsync(TypeMake);

            await _dataContext.SaveChangesAsync();

            return(TypeMake);
        }