コード例 #1
0
        /// <summary>
        /// Verifies Recipe Brew Access
        /// </summary>
        bool VerifyBrewSessionAccess(BrewSession brewSession)
        {
            if (brewSession == null || !brewSession.WasBrewedBy(this.ActiveUser.UserId))
            {
                return(false);
            }

            return(true);
        }
コード例 #2
0
        /// <summary>
        /// Deletes a BrewSession
        /// </summary>
        public void DeleteBrewSession(BrewSession brewSession)
        {
            if (brewSession == null)
            {
                throw new ArgumentNullException("brewSession");
            }

            brewSession.IsActive     = false;
            brewSession.IsPublic     = false;
            brewSession.DateModified = DateTime.Now;
        }
コード例 #3
0
        /// <summary>
        /// Adds a new Recipe Brew
        /// </summary>
        public void AddNewBrewSession(BrewSession brewSession)
        {
            if (brewSession == null)
            {
                throw new ArgumentNullException("brewSession");
            }

            brewSession.UserId      = this.UserResolver.Resolve().UserId;
            brewSession.DateCreated = DateTime.Now;
            brewSession.IsActive    = true;
            brewSession.IsPublic    = true;

            this.Repository.Add(brewSession);
        }
コード例 #4
0
        public string LogSession(SessionViewModel model)
        {
            Console.WriteLine("LogSession");

            if (string.IsNullOrWhiteSpace(model.session))
            {
                var recipe = RecipeLoader.Recipes.Where(p => p.Hash == model.recipe).FirstOrDefault();

                if (recipe != null)
                {
                    BrewSession session = new BrewSession(recipe);

                    _Sessions.TryAdd(session.SessionId, session);

                    return(session.SessionId);
                }
                else
                {
                    return(string.Empty);
                }
            }
            else
            {
                BrewSession session = null;

                if (_Sessions.ContainsKey(model.session))
                {
                    session = _Sessions[model.session];
                }

                if (session != null)
                {
                    switch (model.code)
                    {
                    //new step
                    case 1:
                        session.CurrentStep = model.step;

                        Console.WriteLine("LogSession new step " + model.data);

                        break;

                    //data readings
                    case 2:
                        session.DataReadings.Add(model.data);
                        Console.WriteLine("LogSession " + model.data);

                        break;

                    //end session
                    case 3:

                        _Sessions.Remove(model.session, out session);

                        break;
                    }
                }


                return(string.Empty);
            }
        }