Пример #1
0
        public IActionResult Post([FromBody] SavedGrid grid)
        {
            var auth  = new AuthenticationController();
            var db    = new SmartPulseContext();
            var token = Request.Cookies["token"];
            var user  = auth.isLogin(token);

            if (user != null)
            {
                var exist = db.SavedGrids.FirstOrDefault(g => g.name == grid.name && g.user.email == user.email);
                if (exist != null)
                {
                    exist.header = grid.header;
                    exist.rows   = grid.rows;
                    db.SaveChanges();
                    return(Ok(new { message = "success" }));
                }
                var thisUser = db.Users.FirstOrDefault(u => u.email == user.email);
                grid.user = thisUser;
                db.SavedGrids.Add(grid);
                db.SaveChanges();
                return(Ok(new { message = "success" }));
            }
            return(Unauthorized(new { message = "unauthorized" }));
        }
Пример #2
0
        public void store()
        {
            Matrix matrix = new Matrix(row, col, room);

            matrix.data = this.data;
            SavedGrid savedGrid = new SavedGrid(matrix);

            savedGrid.Show();
        }