Exemplo n.º 1
0
        /// <summary>
        /// Create or update the recipe.
        /// </summary>
        public void Save()
        {
            bool isNew = _id == ObjectId.Empty;

            MongoManager.Save(this);

            log.Information($"{(isNew ? "Added" : "Updated")} recipe {_id}.");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create or update the ingredient.
        /// </summary>
        public void Save()
        {
            bool isNew = _id == ObjectId.Empty;

            if (!isNew && !MongoManager.ItemExists <Users>(x => x.Login == Login))
            {
                throw new Exception($"There is no user [{Login}].");
            }

            MongoManager.Save(this);

            log.Information($"{(isNew ? "Added" : "Updated")} user [{Login}] - {_id}.");
        }
Exemplo n.º 3
0
        /// <summary>
        /// Create or update the list of week ingredients.
        /// </summary>
        /// <param name="userId"></param>
        public void Save(ObjectId userId)
        {
            bool isNew = _id == ObjectId.Empty;

            if (!isNew && UserId != userId)
            {
                throw new Exception("This is not your list of week ingredients.");
            }
            else
            {
                UserId = userId;
            }

            MongoManager.Save(this);

            log.Information($"{(isNew ? "Added" : "Updated")} list of week ingredients {_id}.");
        }
Exemplo n.º 4
0
        /// <summary>
        /// Create or update the ingredient.
        /// </summary>
        public void Save()
        {
            bool isNew = _id == ObjectId.Empty;

            switch (PriceUnit)
            {
            case IngredientPriceUnits.Kilogram:
                BaseQuantity = 1000;
                break;

            case IngredientPriceUnits.Liter:
                BaseQuantity = 100;
                break;

            case IngredientPriceUnits.Piece:
                BaseQuantity = 1;
                break;
            }

            MongoManager.Save(this);

            log.Information($"{(isNew ? "Added" : "Updated")} ingredient {_id}.");
        }
Exemplo n.º 5
0
 /// <summary>
 /// Create or update the configuration.
 /// </summary>
 public void Save() => MongoManager.Save(this);