Ejemplo n.º 1
0
        public ActionResult Create([Bind(Include = "ID,NanpreNO,MakeUserID,IsPublic,Title,Remarks")] Momo momo)
        {
            if (ModelState.IsValid)
            {
                db.Momoes.Add(momo);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(momo));
        }
Ejemplo n.º 2
0
        // 指定されたグループに参加しているクライアントへメッセージを送信する
        public void Send(string momo_id, string displayName, string message)
        {
            var talk = new Talk
            {
                Momo_ID         = int.Parse(momo_id),
                DisplayName     = displayName,
                Message         = message,
                CreatedDateTime = DateTime.Now,
                SenderUser_ID   = Context.ConnectionId
            };

            db.Talks.Add(talk);
            db.SaveChanges();

            Clients.Group("nngo" + momo_id).Receive(talk, talk.CreatedDateTime.ToShortDateString() + " " + talk.CreatedDateTime.ToShortTimeString());
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 数字を入力した際に発火
        /// </summary>
        /// <param name="id"></param>
        /// <param name="number"></param>
        public void InputNumber(string id, string number, string groupName)
        {
            Clients.Group(groupName).inputNumber(id, number, Context.ConnectionId);

            var momo_id = int.Parse(groupName.Replace("nngo", ""));

            id = id.Replace(@"#trout", "");
            var index = int.Parse(id) - 10 - int.Parse(id.Substring(0, 1));

            using (var momoDB = new MomoDBContext())
            {
                var hoge = momoDB.MomoStates.FirstOrDefault(x => x.Momo_ID == momo_id);
                if (hoge == null)
                {
                    return;
                }

                hoge.CurrentNanpre = hoge.CurrentNanpre.ChangeCharAt(index, number);
                momoDB.SaveChanges();
            }
        }
Ejemplo n.º 4
0
        public ActionResult Create([Bind(Include = "ID,NanpreNO,MakeUserID,IsPublic,Title,Remarks")] Momo momo)
        {
            if (ModelState.IsValid)
            {
                //SaveChangesを二回行うので本当は両方を範囲としたトランザクションが必要
                momo.CreatedDateTime = DateTime.Now;
                momo.IsCleared       = false;
                db.Momoes.Add(momo);
                db.SaveChanges();

                var momoState = new MomoState()
                {
                    Momo_ID       = momo.ID,
                    CurrentNanpre = db.NanpreQuestions.FirstOrDefault(x => x.ID == momo.NanpreNO).Nanpre
                };
                //CurrentNanpreがnullの場合の対応はいつかやる
                db.MomoStates.Add(momoState);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(momo));
        }