Exemple #1
0
        public ActionResult CommentId(string retroId)
        {
            var retroGuid = Guid.Parse(retroId);

            var cookies = this.HttpContext.Request.Cookies;

            var userCookie = cookies["sr_user"];

            var commentGuid = Guid.NewGuid();

            if (userCookie == null)
            {
                return(RedirectToRoute("Login-Route", new { id = retroId }));
            }
            else
            {
                var jwtToken = new JwtToken().DecodedValue(userCookie.Value);

                var payload = JsonConvert.DeserializeObject <Dictionary <string, object> >(jwtToken["Payload"]);

                var userGuid = Guid.Parse(payload["sr_uid"].ToString());

                using (var context = new SpeedyRetroDbContext())
                {
                    var user = context.Users
                               .Where(u => u.Guid == userGuid)
                               .Single();

                    var startLane = context.Lanes
                                    .Where(l => l.Id == 1)
                                    .Single();

                    var board = context.Boards
                                .Where(b => b.Retrospective.Guid == retroGuid)
                                .Single();

                    var comment = new Comment
                    {
                        Board = board,
                        Guid  = commentGuid,
                        Lane  = startLane,
                        User  = user
                    };

                    context.Comments.Add(comment);

                    context.SaveChanges();
                }
            }

            return(Json(new { id = commentGuid }, JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
        public async Task <JsonResult> AddRetro(string name)
        {
            var retroId = Guid.NewGuid();

            using (var context = new SpeedyRetroDbContext())
            {
                var defaultPool = context.Pools
                                  .Include("Lanes")
                                  .Where(p => p.Id == 1)
                                  .Single();

                var pool = new Pool
                {
                    Lanes = defaultPool.Lanes,
                    Name  = "New Pool"
                };

                var board = new Board
                {
                    Name   = "New Board",
                    Pool   = pool,
                    PoolId = 1
                };

                var retrospective = new Retrospective
                {
                    Board = board,
                    Guid  = retroId,
                    Name  = name
                };

                context.Retrospectives.Add(retrospective);

                context.SaveChanges();

                board.RetrospectiveId = retrospective.Id;

                pool.BoardId = board.Id;

                await context.SaveChangesAsync();
            }

            return(Json(new { id = retroId }, JsonRequestBehavior.AllowGet));
        }