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))); }
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); }
public IActionResult GetDetails(long id) { try { return(Ok(RecipeMapper.map(recipeRepository.GetRecipeById(id)))); } catch (Exception) { return(BadRequest()); } }
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))); }
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); }
public void Update_FromSeeded_DoesNotThrow() { //Arrange var detailModel = RecipeMapper.MapToDetailModel(CookBookSeedingDbContext.RecipeEntity); detailModel.Name = "Changed recipe name"; //Act & Assert RepositorySUT.InsertOrUpdate(detailModel); }
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))); } }
public void GetAll_FromSeeded_DoesNotThrowAndEqualsSeeded() { //Arrange RecipeListModel listModel = RecipeMapper.MapEntityToListModel(RecipeSeeds.RecipeEntity); //Act IEnumerable <RecipeListModel> returnedModel = _repositorySUT.GetAll(); //Assert Assert.Equal(new [] { listModel }, returnedModel); }
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); }
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); }
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); }
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)); } }
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(); }
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); }
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); }
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); }
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); }
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; } }
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" }; }
public GetAllRecipesQuery(Func <CookBookDbContext> dbContextFactory) { this.dbContextFactory = dbContextFactory; this.mapper = new RecipeMapper(); }
public void AddItem(RecipeModel item) { RecipeRepository.Add(RecipeMapper.ConvertRecipeModelToRecipe(item)); }
public void UpdateItem(RecipeModel item) { RecipeRepository.Update(RecipeMapper.ConvertRecipeModelToRecipe(item)); }
public CrudFactoryRecipe() { mapper = new RecipeMapper(); dao = SqlDao.GetInstance(); }
public RecipeController(IRecipeService recipeService) { this._recipeService = recipeService; this._recipeMapper = new RecipeMapper(); }
public ViewModelLocator() { var recipeMapper = new RecipeMapper(); _recipeRepository = new RecipeRepository(recipeMapper); }
public RecipeFileRepository(IFileReader loader, RecipeMapper mapper) : base(loader, mapper) { }