public void CreateTest()
        {
            Y                  = new Yeast();
            Y.ProductId        = "EE101RED";
            Y.MinTemp          = 2.0;
            Y.MaxTemp          = 44.22;
            Y.Form             = "Non-Newtonian";
            Y.Laboratory       = "S.T.A.R. Labs";
            Y.Flocculation     = "I'm not giggling you are..";
            Y.Attenuation      = 1.21;
            Y.MaxReuse         = Int32.MaxValue;
            Y.Type             = "Flux Capacitance";
            Y.BestFor          = "Time travel";
            I                  = new Ingredient();
            I.Name             = "The Time Traveler";
            I.IngredientTypeId = 4;
            I.Version          = 1;
            I.OnHandQuantity   = 0;
            I.UnitCost         = 0.00m;
            I.UnitTypeId       = 2;
            I.Notes            = "A swirling mass of wibbly wobbly colourful time stuff";
            dbContext.Ingredient.Add(I);
            dbContext.SaveChanges();
            Y.IngredientId = I.IngredientId;
            dbContext.Yeast.Add(Y);
            dbContext.SaveChanges();
            List <Ingredient> myIngredient = dbContext.Ingredient.Where(I => I.Name == "The Time Traveler").ToList();

            Assert.IsNotNull(dbContext.Ingredient.Find(I.IngredientId));
            List <Yeast> myyeast = dbContext.Yeast.Where(Y => Y.ProductId == "EE101RED").ToList();

            Assert.IsNotNull(dbContext.Yeast.Find(Y.IngredientId));
        }
Exemplo n.º 2
0
        public async Task <int> UpdateAsync(Yeast yeast)
        {
            using (DbConnection connection = new NpgsqlConnection(_databaseSettings.DbConnection))
            {
                connection.Open();
                using (var transaction = connection.BeginTransaction())
                {
                    try
                    {
                        var result = await connection.ExecuteAsync(
                            "UPDATE Yeasts set name = @Name,temperature_high = @TemperatureHigh,temperature_low = @TemperatureLow,flocculation = @Flocculation," +
                            "alcohol_tolerance = @AlcoholTolerance,product_code = @ProductCode, notes = @Notes, type = @Type, brewery_source = @BrewerySource, species = @Species," +
                            "attenution_range = @AttenuationRange, pitching_fermentation_notes = @PitchingFermentationNotes, supplier_id = @SupplierId, custom = @Custom, " +
                            "flocculation_low = @FlocculationLow, flocculation_high = @FlocculationHigh, attenution_low = @AttenuationLow, attenution_high = @AttenuationHigh, alcohol_tolerance_low = @AlcoholToleranceLow, alcohol_tolerance_high = @AlcoholToleranceHigh " +
                            "WHERE yeast_id = @YeastId;", yeast, transaction);
                        await UpdateYeastSources(yeast, connection, transaction);
                        await InsertYeastFlavours(yeast, connection, transaction);

                        transaction.Commit();
                        return(result);
                    }
                    catch (Exception exception)
                    {
                        _logger.LogError(exception.ToString());
                        transaction.Rollback();
                        throw;
                    }
                }
            }
        }
Exemplo n.º 3
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (targeted is Yeast)
                {
                    Yeast yeast = targeted as Yeast;

                    if (yeast.IsChildOf(from.Backpack))
                    {
                        if (!m_Context.YeastInUse(yeast))
                        {
                            m_Context.SelectedYeast[m_Index] = yeast;
                            from.SendLocalizedMessage(1150740); // You have chosen the yeast.
                        }
                        else
                        {
                            from.SendLocalizedMessage(1150742); // You have already chosen other yeast.
                        }
                    }
                    else
                    {
                        from.SendLocalizedMessage(1054107); // This item must be in your backpack.
                    }
                }
                else
                {
                    from.SendLocalizedMessage(1150741); // That is not yeast.
                }
                from.SendGump(new DistillationGump(from));
            }
Exemplo n.º 4
0
        public async Task AddAsync(Yeast yeast)
        {
            using (DbConnection connection = new NpgsqlConnection(_databaseSettings.DbConnection))
            {
                connection.Open();
                using (var transaction = connection.BeginTransaction())
                {
                    try
                    {
                        var result = await connection.ExecuteAsync("INSERT INTO yeasts(name,temperature_high,temperature_low,flocculation,alcohol_tolerance,product_code,notes,type,brewery_source,species,attenution_range,pitching_fermentation_notes,supplier_id,custom, flocculation_low,flocculation_high,attenution_low,attenution_high,alcohol_tolerance_low,alcohol_tolerance_high) VALUES (@Name,@TemperatureHigh,@TemperatureLow,@Flocculation,@AlcoholTolerance,@ProductCode,@Notes,@Type,@BrewerySource,@Species,@AttenuationRange,@PitchingFermentationNotes, @SupplierId, @Custom, @FlocculationLow,@FlocculationHigh,@AttenuationLow,@AttenuationHigh,@AlcoholToleranceLow,@AlcoholToleranceHigh);",
                                                                   yeast, transaction);

                        var yeastId = await connection.QueryAsync <int>("SELECT last_value FROM yeasts_seq;");

                        yeast.YeastId = yeastId.SingleOrDefault();
                        await InsertYeastSources(yeast, connection, transaction);
                        await InsertYeastFlavours(yeast, connection, transaction);

                        transaction.Commit();
                    }
                    catch (Exception e)
                    {
                        _logger.LogError(e.ToString());
                        transaction.Rollback();
                    }
                }
            }
        }
 public void GetByPrimaryKeyTest()
 {
     Y = dbContext.Yeast.Find(272);
     Assert.IsNotNull(Y);
     Assert.AreEqual("White Labs", Y.Laboratory);
     Console.WriteLine(Y);
 }
Exemplo n.º 6
0
 private async Task InsertYeastSources(Yeast yeast, DbConnection connection, DbTransaction transaction)
 {
     foreach (var source in yeast?.Sources)
     {
         await connection.ExecuteAsync("INSERT INTO yeast_sources (yeast_id, social_id, site, url) VALUES(@YeastId,@SocialId,@Site,@Url);", new { yeast.YeastId, source.SocialId, source.Site, source.Url }, transaction);
     }
 }
Exemplo n.º 7
0
        public void Add(Yeast yeast)
        {
            using (var context = new MicrobrewitContext())
            {
                if (yeast.Supplier != null)
                {
                    yeast.Supplier = null;
                }

                context.Entry(yeast).State = EntityState.Added;
                try
                {
                    context.SaveChanges();
                }
                catch (DbEntityValidationException dbEx)
                {
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                            Log.DebugFormat("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                        }
                    }
                }
            }
        }
Exemplo n.º 8
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,Name,AmountIsWeight")] Yeast yeast)
        {
            if (id != yeast.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(yeast);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!YeastExists(yeast.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(yeast));
        }
Exemplo n.º 9
0
        public Yeast SaveYeast(Yeast yeast, string userEmail)
        {
            var collection     = GetYeastCollection(userEmail);
            var usersYeastList = GetYeastCollectionForUser(collection, userEmail);

            if (usersYeastList == null)
            {
                //this should not happen
                CreateNewYeastCollection(userEmail, collection);
                return(SaveYeast(yeast, userEmail));
            }
            var yeastToUpdate = usersYeastList.Yeast.SingleOrDefault(y => y.Id == yeast.Id);

            if (yeastToUpdate == null)
            {
                yeast.Id = Guid.NewGuid();
            }
            else
            {
                usersYeastList.Yeast.Remove(yeastToUpdate);
            }
            usersYeastList.Yeast.Add(yeast);
            var collectionId = usersYeastList.Id;
            var filter       = Builders <YeastCollection> .Filter.Eq(f => f.Id, collectionId);

            collection.ReplaceOne(filter, usersYeastList);
            return(yeast);
        }
        public async Task <IActionResult> PutYeast(int id, Yeast yeast)
        {
            if (id != yeast.IngredientId)
            {
                return(BadRequest());
            }

            _context.Entry(yeast).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!YeastExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 11
0
        public async Task <Yeast> Update(Yeast yeast)
        {
            var entityEntry = _dataContext.Yeasts.Update(yeast);
            await _dataContext.SaveChangesAsync();

            return(entityEntry.Entity);
        }
Exemplo n.º 12
0
        public IHttpActionResult PutYeast(int id, Yeast yeast)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != yeast.Id)
            {
                return(BadRequest());
            }

            db.Entry(yeast).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!YeastExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 13
0
            private bool HasTotal(Mobile from, double percentage)
            {
                for (int i = 0; i < m_Def.Ingredients.Length; i++)
                {
                    Type type      = m_Def.Ingredients[i];
                    int  toConsume = m_Def.Amounts[i];

                    if (i == 0 && type == typeof(Yeast))
                    {
                        for (int j = 0; j < toConsume; j++)
                        {
                            Yeast yeast = m_Context.SelectedYeast[j];

                            if (yeast == null || !yeast.IsChildOf(from.Backpack))
                            {
                                return(false);
                            }
                        }
                    }
                    else
                    {
                        toConsume = (int)((double)toConsume * percentage);

                        if (GetAmount(from, type, m_Def.Liquor) < toConsume)
                        {
                            return(false);
                        }
                    }
                }

                return(true);
            }
Exemplo n.º 14
0
 private async Task UpdateYeastSources(Yeast yeast, DbConnection connection, DbTransaction transaction)
 {
     foreach (var source in yeast?.Sources)
     {
         await connection.ExecuteAsync("UPDATE yeast_sources SET site = @Site, url = @Url WHERE yeast_id = @YeastId AND social_id = @SocialId;", new { yeast.YeastId, source.SocialId, source.Site, source.Url }, transaction);
     }
 }
Exemplo n.º 15
0
 public virtual async Task AddAsync(Yeast yeast)
 {
     using (var context = new MicrobrewitContext())
     {
         if (yeast.Supplier != null)
         {
             yeast.Supplier = null;
         }
         context.Entry(yeast).State = EntityState.Added;
         try
         {
             await context.SaveChangesAsync();
         }
         catch (DbEntityValidationException dbEx)
         {
             //foreach (var validationErrors in dbEx.EntityValidationErrors)
             //{
             //    foreach (var validationError in validationErrors.ValidationErrors)
             //    {
             //        Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
             //        Log.DebugFormat("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
             //        throw dbEx;
             //    }
             //}
             throw;
         }
         catch (Exception ex)
         {
             throw;
         }
     }
 }
Exemplo n.º 16
0
        public async void CreateYeast_WithInvalidYeast_ReturnsBadRequest()
        {
            var yeast       = new Yeast();
            var accessToken = AuthHelper.GetAccessToken();
            var response    = await Client.PostJsonAsync(YeastBaseUrl, yeast, accessToken, isContentCreator : true);

            response.StatusCode.Should().Be(HttpStatusCode.BadRequest);
        }
Exemplo n.º 17
0
 public virtual void Remove(Yeast yeast)
 {
     using (var context = new MicrobrewitContext())
     {
         context.Entry(yeast).State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Exemplo n.º 18
0
 public virtual void Update(Yeast yeast)
 {
     using (var context = new MicrobrewitContext())
     {
         context.Entry(yeast).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Exemplo n.º 19
0
    public void OnTransferWortIn(Recipe recipeIn)
    {
        recipe = recipeIn;
        Yeast yeast = GameObject.Find("CompanyController").GetComponent <CompanyController>().inventory.availableYeasts[recipe.yeastIndex];

        gravityDropPerTimeStep = (yeast.speed / (float)dayLength);
        currentGravity         = recipe.startingGravity;
        fermenting             = true;
    }
Exemplo n.º 20
0
 public Beer(List <Hops> hops, Malt malt, Barley barley, Water water, Yeast yeast, List <Extras> extras)
 {
     this.hops   = hops;
     this.malt   = malt;
     this.barley = barley;
     base.water  = water;
     this.yeast  = yeast;
     this.extras = extras;
 }
Exemplo n.º 21
0
 public Beer(List<Hops> hops, Malt malt, Barley barley, Water water, Yeast yeast, List<Extras> extras )
 {
     this.hops = hops;
     this.malt = malt;
     this.barley = barley;
     base.water = water;
     this.yeast = yeast;
     this.extras = extras;
 }
Exemplo n.º 22
0
        public void Yeast_Valid()
        {
            Yeast yeast = new Yeast(
                YeastType.Ale,
                YeastForm.Culture,
                3,
                "Test");

            Assert.IsTrue(yeast.IsValid());
        }
Exemplo n.º 23
0
        public async void CreateYeast_WithoutAuthHeader_ReturnsUnauthorized()
        {
            var yeast = new Yeast
            {
                Name = "SafAle American Ale",
            };
            var response = await Client.PostJsonAsync(YeastBaseUrl, yeast);

            response.StatusCode.Should().Be(HttpStatusCode.Unauthorized);
        }
Exemplo n.º 24
0
        private void ChangeYeast(Yeast yeastInfo)
        {
            if (CurrentRecipe.YeastIngredient == null)
            {
                CurrentRecipe.YeastIngredient = YeastUtility.CreateYeastIngredient();
            }

            CurrentRecipe.YeastIngredient.YeastInfo = yeastInfo;
            CurrentRecipe.UpdateRecipeOutcome();
        }
Exemplo n.º 25
0
 public ActionResult CreateYeast(Yeast yeast)
 {
     if (!IsContentCreator())
     {
         return(new ForbidResult());
     }
     _logger.LogInformation("Creating yeast '{name}'", yeast.Name);
     _homebrewingDbService.CreateYeast(yeast);
     return(new OkResult());
 }
Exemplo n.º 26
0
        public void Add_YeastId_Gets_Set()
        {
            var newYeast = new Yeast {
                Name = "newYeast" + DateTime.Now.Ticks, ProductCode = "AAA", Type = "Liquid", Custom = true
            };

            _yeastRepository.Add(newYeast);
            var yeast = _yeastRepository.GetSingle(newYeast.YeastId);

            Assert.NotNull(yeast);
        }
Exemplo n.º 27
0
        public void Add_Gets_Added()
        {
            var newYeast = new Yeast {
                Name = "newYeast" + DateTime.Now.Ticks, ProductCode = "AAA", Type = "Liquid", Custom = true
            };

            _yeastRepository.Add(newYeast);
            var yeasts = _yeastRepository.GetAll();

            Assert.True(yeasts.Any(o => o.Name == newYeast.Name));
        }
Exemplo n.º 28
0
        public IHttpActionResult GetYeast(int id)
        {
            Yeast yeast = db.Yeasts.Find(id);

            if (yeast == null)
            {
                return(NotFound());
            }

            return(Ok(yeast));
        }
Exemplo n.º 29
0
        public async void CreateYeast_SuccessfullyCreatesYeast()
        {
            var yeast = new Yeast
            {
                Name = "SafAle American Ale",
            };
            var accessToken = AuthHelper.GetAccessToken();
            var response    = await Client.PostJsonAsync(YeastBaseUrl, yeast, accessToken, isContentCreator : true);

            response.StatusCode.Should().Be(HttpStatusCode.OK);
        }
Exemplo n.º 30
0
        public async void CreateYeast_WithEndUserCredential_ReturnsForbidden()
        {
            var yeast = new Yeast
            {
                Name = "SafAle American Ale",
            };
            var accessToken = AuthHelper.GetAccessToken();
            var response    = await Client.PostJsonAsync(YeastBaseUrl, yeast, accessToken);

            response.StatusCode.Should().Be(HttpStatusCode.Forbidden);
        }
Exemplo n.º 31
0
        public async Task <IHttpActionResult> GetYeast(int id)
        {
            Yeast yeast = await db.Yeasts.FindAsync(id);

            if (yeast == null)
            {
                return(NotFound());
            }

            return(Ok(yeast));
        }
Exemplo n.º 32
0
		public void CheckQuest()
		{
			List<DamageStore> rights = BaseCreature.GetLootingRights( this.DamageEntries, this.HitsMax );

			ArrayList mobile = new ArrayList();

			for ( int i = rights.Count - 1; i >= 0; --i )
			{
				DamageStore ds = rights[i];

				if ( ds.m_HasRight )
				{
					if ( ds.m_Mobile is PlayerMobile )
					{
						PlayerMobile pm = (PlayerMobile)ds.m_Mobile;
						QuestSystem qs = pm.Quest;
						if ( qs is TheGraveDiggerQuest )
						{
							mobile.Add( ds.m_Mobile );
						}
					}
				}
			}

			for ( int i = 0; i < mobile.Count; ++i )
			{
				PlayerMobile pm = (PlayerMobile)mobile[i % mobile.Count];
				QuestSystem qs = pm.Quest;

				QuestObjective obj = qs.FindObjective( typeof( FindYeastObjective ) );

				if ( obj != null && !obj.Completed )
				{
					Item yeast = new Yeast();

					if ( !pm.PlaceInBackpack( yeast ) )
					{
						yeast.Delete();
						pm.SendLocalizedMessage( 1046260 ); // You need to clear some space in your inventory to continue with the quest.  Come back here when you have more space in your inventory.
					}
					else
					{
						obj.Complete();
						pm.SendMessage( "You loot the yeast off the farmers corpse." );
					}
				}
			}	
		}
Exemplo n.º 33
0
 internal static YeastIngredientDataModel GetYeastIngredientForRecipe(int recipeId, SQLiteConnection connection)
 {
     using (SQLiteCommand selectIngredientsCommand = connection.CreateCommand())
     {
         selectIngredientsCommand.CommandText = "SELECT YeastIngredients.id, YeastIngredients.weight, YeastIngredients.volume, Yeasts.id, Yeasts.name, Yeasts.type, Yeasts.form, Yeasts.laboratory, Yeasts.productId, Yeasts.minTemperature, Yeasts.maxTemperature, Yeasts.flocculation, Yeasts.attenuation, Yeasts.notes FROM YeastIngredients " +
             "JOIN Recipes ON Recipes.yeastIngredientInfo = YeastIngredients.id AND Recipes.id = @recipeId " +
             "JOIN Yeasts ON Yeasts.id = YeastIngredients.yeastInfo " +
             "LIMIT 1";
         selectIngredientsCommand.Parameters.AddWithValue("recipeId", recipeId);
         using (SQLiteDataReader reader = selectIngredientsCommand.ExecuteReader())
         {
             while (reader.Read())
             {
                 YeastCharacteristics characteristics = new YeastCharacteristics(reader.GetString(5), reader.GetString(11), reader.GetString(6))
                 {
                     Attenuation = reader.GetFloat(12),
                     MinTemperature = reader.GetFloat(9),
                     MaxTemperature = reader.GetFloat(10)
                 };
                 Yeast yeastInfo = new Yeast(reader.GetString(4), characteristics, reader.GetString(13), reader.GetString(7), reader.GetString(8));
                 return new YeastIngredientDataModel(yeastInfo, reader.GetInt32(0)) { Volume = reader.GetFloat(2), Weight = reader.GetFloat(1) };
             }
         }
     }
     return null;
 }
Exemplo n.º 34
0
 public YeastIngredient(Yeast yeastInfo)
 {
     m_yeastInfo = yeastInfo;
 }