示例#1
0
        public void Update(Coords grid)
        {
            if (!ModelState.IsValid)
                throw HttpExceptionFactory.InvalidModel();
            if(!userDb.CoordsAllowed(User.Identity.Name, grid) && !User.IsInRole("Admin"))
                throw HttpExceptionFactory.Forbidden();

            db.UpdateCoord(grid.coords);
        }
示例#2
0
        public bool CoordsAllowed(string login, Coords coords)
        {
            var ids = GetUsersItemsIdForGrid(login, coords.GridId);
            coords.coords = coords.coords.OrderBy(coord => coord[0]).ToArray();

            if (ids.Count != coords.coords.Length)
                return false;
                
            for (var i = 0; i < ids.Count; i++)
                if (ids[i] != coords.coords[i][0])
                    return false;

            return true;
        }