Esempio n. 1
0
        public IHttpActionResult Create(RecipeViewModel model)
        {
            Recipe recipe = new Recipe()
            {
                Name        = model.Name,
                Description = model.Description
            };

            foreach (RecipeProductsViewModel recipeProduct in model.Products)
            {
                Product product = _context.Products.Where(x => x.Id == recipeProduct.Product.Id).FirstOrDefault();
                if (product != null)
                {
                    recipe.RecipeProducts.Add(new RecipeProducts()
                    {
                        Product = product,
                        Weight  = recipeProduct.Weight
                    });
                }
            }
            _context.Recipes.Add(recipe);
            _context.SaveChanges();

            return(Ok(RecipeMapper.RecipeViewModelMapper(recipe)));
        }
Esempio n. 2
0
        public void Delete_FromSeeded_DoesNotThrow()
        {
            //Arrange
            var detailModel = RecipeMapper.MapToDetailModel(CookBookSeedingDbContext.RecipeEntity);

            //Act & Assert
            RepositorySUT.Delete(detailModel);
        }
        public void Delete_FromSeeded_DoesNotThrow()
        {
            //Arrange
            RecipeDetailModel detailModel = RecipeMapper.MapEntityToDetailModel(DAL.Seeds.RecipeSeeds.RecipeEntity);

            //Act & Assert
            _repositorySUT.Delete(detailModel);
        }
Esempio n. 4
0
 public IActionResult GetDetails(long id)
 {
     try {
         return(Ok(RecipeMapper.map(recipeRepository.GetRecipeById(id))));
     } catch (Exception)
     {
         return(BadRequest());
     }
 }
Esempio n. 5
0
        public IHttpActionResult GetRecipe(int id)
        {
            Recipe recipe = _context.Recipes.Include(x => x.RecipeProducts.Select(xx => xx.Product)).Include(x => x.Images).Where(x => x.Id == id && x.IsDeleted == false).FirstOrDefault();

            if (recipe == null)
            {
                return(NotFound());
            }
            return(Ok(RecipeMapper.RecipeViewModelMapper(recipe)));
        }
Esempio n. 6
0
        public IHttpActionResult GetRecipes()
        {
            ICollection <RecipeViewModel> recipes = _context.Recipes
                                                    .Include(x => x.RecipeProducts.Select(xx => xx.Product))
                                                    .Include(x => x.Images)
                                                    .Where(x => x.IsDeleted == false).ToList()
                                                    .Select(x => RecipeMapper.RecipeViewModelMapper(x)).ToList();

            return(Ok(recipes));
        }
        public void Update_FromSeeded_DoesNotThrow()
        {
            //Arrange
            RecipeDetailModel detailModel = RecipeMapper.MapEntityToDetailModel(DAL.Seeds.RecipeSeeds.RecipeEntity);

            detailModel.Name = "Changed recipe name";

            //Act & Assert
            _repositorySUT.InsertOrUpdate(detailModel);
        }
Esempio n. 8
0
        public void Update_FromSeeded_DoesNotThrow()
        {
            //Arrange
            var detailModel = RecipeMapper.MapToDetailModel(CookBookSeedingDbContext.RecipeEntity);

            detailModel.Name = "Changed recipe name";

            //Act & Assert
            RepositorySUT.InsertOrUpdate(detailModel);
        }
Esempio n. 9
0
 public IEnumerable <RecipeDto> Get([FromQuery] RecipeDifficulty?difficulty)
 {
     if (difficulty == null)
     {
         return(recipeRepository.GetRecipes().Select(r => RecipeMapper.map(r)));
     }
     else
     {
         return(recipeRepository.GetRecipesByDifficulty((RecipeDifficulty)difficulty).Select(r => RecipeMapper.map(r)));
     }
 }
Esempio n. 10
0
        public void GetAll_FromSeeded_DoesNotThrowAndEqualsSeeded()
        {
            //Arrange
            RecipeListModel listModel = RecipeMapper.MapEntityToListModel(RecipeSeeds.RecipeEntity);

            //Act
            IEnumerable <RecipeListModel> returnedModel = _repositorySUT.GetAll();

            //Assert
            Assert.Equal(new [] { listModel }, returnedModel);
        }
Esempio n. 11
0
        public void GetAll_FromSeeded_DoesNotThrowAndEqualsSeeded()
        {
            //Arrange
            var listModel = RecipeMapper.MapToListModel(CookBookSeedingDbContext.RecipeEntity);

            //Act
            var returnedModel = RepositorySUT.GetAll();

            //Assert
            Assert.Equal(new [] { listModel }, returnedModel, RecipeListModel.NameDurationFoodTypeComparer);
        }
Esempio n. 12
0
        public void GetById_FromSeeded_DoesNotThrowAndEqualsSeeded()
        {
            //Arrange
            RecipeDetailModel detailModel = RecipeMapper.MapEntityToDetailModel(DAL.Seeds.RecipeSeeds.RecipeEntity);

            //Act
            RecipeDetailModel returnedModel = _repositorySUT.GetById(detailModel.Id);

            //Assert
            Assert.Equal(detailModel, returnedModel);
        }
Esempio n. 13
0
        public void GetById_FromSeeded_DoesNotThrowAndEqualsSeeded()
        {
            //Arrange
            var detailModel = RecipeMapper.MapToDetailModel(CookBookSeedingDbContext.RecipeEntity);

            //Act
            var returnedModel = RepositorySUT.GetById(detailModel.Id);

            //Assert
            Assert.Equal(detailModel, returnedModel, RecipeDetailModel.RecipeDetailModelComparer);
        }
Esempio n. 14
0
        public async Task <Recipe> GetRecipeAsync(IAuthenticationScope authenticationScope, RecipeId recipeId)
        {
            var mapper      = new RecipeMapper(recipeId.Id);
            var artisanSlug = EnumConversionHelper.ArtisanIdentifierToString(recipeId.Id);

            using (var client = CreateClient(authenticationScope))
            {
                var recipe = await client.GetRecipeAsync(artisanSlug, recipeId.Slug);

                return(mapper.Map(recipe));
            }
        }
Esempio n. 15
0
 public Mapper()
 {
     _accountMapper           = new AccountMapper();
     _bazaarItemMapper        = new BazaarItemMapper();
     _bCardMapper             = new BCardMapper();
     _boxItemMapper           = new ItemInstanceMapper();
     _cardMapper              = new CardMapper();
     _cellonOptionMapper      = new CellonOptionMapper();
     _characterMapper         = new CharacterMapper();
     _characterRelationMapper = new CharacterRelationMapper();
     _characterSkillMapper    = new CharacterSkillMapper();
     _comboMapper             = new ComboMapper();
     _dropMapper              = new DropMapper();
     _familyCharacterMapper   = new FamilyCharacterMapper();
     _familyLogMapper         = new FamilyLogMapper();
     _familyMapper            = new FamilyMapper();
     _generalLogMapper        = new GeneralLogMapper();
     _itemInstanceMapper      = new ItemInstanceMapper();
     _itemMapper              = new ItemMapper();
     _mailMapper              = new MailMapper();
     _maintenanceLogMapper    = new MaintenanceLogMapper();
     _mapMapper               = new MapMapper();
     _mapMonsterMapper        = new MapMonsterMapper();
     _mapNPCMapper            = new MapNPCMapper();
     _mapTypeMapMapper        = new MapTypeMapMapper();
     _mapTypeMapper           = new MapTypeMapper();
     _mateMapper              = new MateMapper();
     _minilandObjectMapper    = new MinilandObjectMapper();
     _npcMonsterMapper        = new NpcMonsterMapper();
     _npcMonsterSkillMapper   = new NpcMonsterSkillMapper();
     _penaltyLogMapper        = new PenaltyLogMapper();
     _portalMapper            = new PortalMapper();
     _questMapper             = new QuestMapper();
     _questProgressMapper     = new QuestProgressMapper();
     _quicklistEntryMapper    = new QuicklistEntryMapper();
     _recipeItemMapper        = new RecipeItemMapper();
     _recipeListMapper        = new RecipeListMapper();
     _recipeMapper            = new RecipeMapper();
     _respawnMapper           = new RespawnMapper();
     _respawnMapTypeMapper    = new RespawnMapTypeMapper();
     _rollGeneratedItemMapper = new RollGeneratedItemMapper();
     _scriptedInstanceMapper  = new ScriptedInstanceMapper();
     _shellEffectMapper       = new ShellEffectMapper();
     _shopItemMapper          = new ShopItemMapper();
     _shopMapper              = new ShopMapper();
     _shopSkillMapper         = new ShopSkillMapper();
     _skillMapper             = new SkillMapper();
     _staticBonusMapper       = new StaticBonusMapper();
     _staticBuffMapper        = new StaticBuffMapper();
     _teleporterMapper        = new TeleporterMapper();
 }
Esempio n. 16
0
        public void Update_RemoveIngredients_FromSeeded_CheckUpdated()
        {
            //Arrange
            var detailModel = RecipeMapper.MapToDetailModel(CookBookSeedingDbContext.RecipeEntity);

            detailModel.Ingredients.Clear();

            //Act
            RepositorySUT.InsertOrUpdate(detailModel);

            //Assert
            var returnedModel = RepositorySUT.GetById(detailModel.Id);

            Assert.Equal(detailModel, returnedModel, RecipeDetailModel.RecipeDetailModelComparer);
        }
Esempio n. 17
0
        public void Update_RemoveIngredients_FromSeeded_CheckUpdated()
        {
            //Arrange
            RecipeDetailModel detailModel = RecipeMapper.MapEntityToDetailModel(DAL.Seeds.RecipeSeeds.RecipeEntity);

            detailModel.Ingredients.Clear();

            //Act
            _repositorySUT.InsertOrUpdate(detailModel);

            //Assert
            RecipeDetailModel returnedModel = _repositorySUT.GetById(detailModel.Id);

            Assert.Equal(detailModel, returnedModel);
        }
Esempio n. 18
0
        public void Update_Name_FromSeeded_CheckUpdated()
        {
            //Arrange
            RecipeDetailModel detailModel = RecipeMapper.MapEntityToDetailModel(DAL.Seeds.RecipeSeeds.RecipeEntity);

            detailModel.Name = "Changed recipe name 1";

            //Act
            _repositorySUT.InsertOrUpdate(detailModel);

            //Assert
            RecipeDetailModel returnedModel = _repositorySUT.GetById(detailModel.Id);

            Assert.Equal(detailModel, returnedModel);
        }
Esempio n. 19
0
        public void Update_Name_FromSeeded_CheckUpdated()
        {
            //Arrange
            var detailModel = RecipeMapper.MapToDetailModel(CookBookSeedingDbContext.RecipeEntity);

            detailModel.Name = "Changed recipe name 1";

            //Act
            RepositorySUT.InsertOrUpdate(detailModel);

            //Assert
            var returnedModel = RepositorySUT.GetById(detailModel.Id);

            Assert.Equal(detailModel, returnedModel, RecipeDetailModel.RecipeDetailModelComparer);
        }
Esempio n. 20
0
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            CommentMapper.Map(modelBuilder.Entity <Comment>());
            IngredientMapper.Map(modelBuilder.Entity <Ingredient>());
            LikeMapper.Map(modelBuilder.Entity <Like>());
            MeasureMapper.Map(modelBuilder.Entity <Measure>());
            RecipeTagMapper.Map(modelBuilder.Entity <RecipeTag>());
            TagMapper.Map(modelBuilder.Entity <Tag>());
            RecipeMapper.Map(modelBuilder.Entity <Recipe>());
            UserMapper.Map(modelBuilder.Entity <User>());

            foreach (var relationship in modelBuilder.Model.GetEntityTypes().SelectMany(e => e.GetForeignKeys()))
            {
                relationship.DeleteBehavior = DeleteBehavior.Restrict;
            }
        }
Esempio n. 21
0
 public RecipeMapperTest()
 {
     subject = new RecipeMapper("generic");
     model   = new Recipe("generic")
     {
         Name        = "Big Fish Stew",
         Hearts      = 3.25,
         Effects     = new [] { "makes you turnt", "is super trill" },
         Ingredients = new [] { "carp", "rice" }
     };
     data = new List <string>
     {
         "Big Fish Stew",
         "❤❤¾½",
         "makes you turnt     %% is super trill  ",
         "carp %% rice"
     };
 }
Esempio n. 22
0
 public GetAllRecipesQuery(Func <CookBookDbContext> dbContextFactory)
 {
     this.dbContextFactory = dbContextFactory;
     this.mapper           = new RecipeMapper();
 }
Esempio n. 23
0
 public void AddItem(RecipeModel item)
 {
     RecipeRepository.Add(RecipeMapper.ConvertRecipeModelToRecipe(item));
 }
Esempio n. 24
0
 public void UpdateItem(RecipeModel item)
 {
     RecipeRepository.Update(RecipeMapper.ConvertRecipeModelToRecipe(item));
 }
 public CrudFactoryRecipe()
 {
     mapper = new RecipeMapper();
     dao    = SqlDao.GetInstance();
 }
Esempio n. 26
0
 public RecipeController(IRecipeService recipeService)
 {
     this._recipeService = recipeService;
     this._recipeMapper  = new RecipeMapper();
 }
        public ViewModelLocator()
        {
            var recipeMapper = new RecipeMapper();

            _recipeRepository = new RecipeRepository(recipeMapper);
        }
Esempio n. 28
0
 public RecipeFileRepository(IFileReader loader, RecipeMapper mapper) : base(loader, mapper)
 {
 }