Exemplo n.º 1
0
        public LastModifiedGuidResponse Post([FromBody] BrewLog value, string id)
        {
            LastModifiedGuidResponse response = new LastModifiedGuidResponse();

            if (value != null)
            {
                try
                {
                    /*
                     * Checks if someone else has modified the recipe.
                     * */
                    if (!String.IsNullOrEmpty(id))
                    {
                        BrewLog existingRecipe = accessor.Get <BrewLog>(id);
                        if (existingRecipe.lastModifiedGuid != value.lastModifiedGuid)
                        {
                            throw new Exception("Recipe has been modified.  Please refresh");
                        }
                    }
                    Guid lastModified = Guid.NewGuid();
                    value.lastModifiedGuid = lastModified;
                    value = GlobalFunctions.AddIdIfNeeded(value, id);

                    accessor.Post <BrewLog>(value);

                    response.lastModifiedGuid = lastModified;
                    response.idString         = value.idString;
                    return(response);
                }
                catch (Exception e)
                {
                    response.Fail(e);
                    return(response);
                }
            }
            else
            {
                response.Message = "No BrewLog given.";
                response.Success = false;
            }

            return(response);
        }
Exemplo n.º 2
0
        public IActionResult Get(string id)
        {
            BrewLog brew = accessor.Get <BrewLog>(id);

            return(Json(brew));
        }